CURLOPT_SSL_VERIFYHOST.3 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_SSL_VERIFYHOST 3 "January 02, 2023" "libcurl 7.88.1" "curl_easy_setopt options"
  26. .SH NAME
  27. CURLOPT_SSL_VERIFYHOST \- verify the certificate's name against host
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYHOST, long verify);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass a long as parameter specifying what to \fIverify\fP.
  35. This option determines whether libcurl verifies that the server cert is for
  36. the server it is known as.
  37. When negotiating TLS and SSL connections, the server sends a certificate
  38. indicating its identity.
  39. When \fICURLOPT_SSL_VERIFYHOST(3)\fP is 2, that certificate must indicate that
  40. the server is the server to which you meant to connect, or the connection
  41. fails. Simply put, it means it has to have the same name in the certificate as
  42. is in the URL you operate against.
  43. Curl considers the server the intended one when the Common Name field or a
  44. Subject Alternate Name field in the certificate matches the host name in the
  45. URL to which you told Curl to connect.
  46. If \fIverify\fP value is set to 1:
  47. In 7.28.0 and earlier: treated as a debug option of some sorts, not supported
  48. anymore due to frequently leading to programmer mistakes.
  49. From 7.28.1 to 7.65.3: setting it to 1 made curl_easy_setopt() return an error
  50. and leaving the flag untouched.
  51. From 7.66.0: treats 1 and 2 the same.
  52. When the \fIverify\fP value is 0, the connection succeeds regardless of the
  53. names in the certificate. Use that ability with caution!
  54. The default value for this option is 2.
  55. This option controls checking the server's certificate's claimed identity.
  56. The server could be lying. To control lying, see
  57. \fICURLOPT_SSL_VERIFYPEER(3)\fP.
  58. WARNING: disabling verification of the certificate allows bad guys to
  59. man-in-the-middle the communication without you knowing it. Disabling
  60. verification makes the communication insecure. Just having encryption on a
  61. transfer is not enough as you cannot be sure that you are communicating with
  62. the correct end-point.
  63. When libcurl uses secure protocols it trusts responses and allows for example
  64. HSTS and Alt-Svc information to be stored and used subsequently. Disabling
  65. certificate verification can make libcurl trust and use such information from
  66. malicious servers.
  67. .SH LIMITATIONS
  68. Secure Transport: If \fIverify\fP value is 0, then SNI is also disabled. SNI is
  69. a TLS extension that sends the hostname to the server. The server may use that
  70. information to do such things as sending back a specific certificate for the
  71. hostname, or forwarding the request to a specific origin server. Some hostnames
  72. may be inaccessible if SNI is not sent.
  73. NSS: If \fICURLOPT_SSL_VERIFYPEER(3)\fP is zero,
  74. \fICURLOPT_SSL_VERIFYHOST(3)\fP is also set to zero and cannot be overridden.
  75. .SH DEFAULT
  76. 2
  77. .SH PROTOCOLS
  78. All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
  79. .SH EXAMPLE
  80. .nf
  81. CURL *curl = curl_easy_init();
  82. if(curl) {
  83. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  84. /* Set the default value: strict name check please */
  85. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
  86. curl_easy_perform(curl);
  87. }
  88. .fi
  89. .SH AVAILABILITY
  90. If built TLS enabled.
  91. .SH RETURN VALUE
  92. Returns CURLE_OK if TLS is supported, and CURLE_UNKNOWN_OPTION if not.
  93. If 1 is set as argument, \fICURLE_BAD_FUNCTION_ARGUMENT\fP is returned.
  94. .SH "SEE ALSO"
  95. .BR CURLOPT_SSL_VERIFYPEER "(3), " CURLOPT_CAINFO "(3), "