CURLOPT_SSL_VERIFYHOST.3 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. .\" generated by cd2nroff 0.1 from CURLOPT_SSL_VERIFYHOST.md
  2. .TH CURLOPT_SSL_VERIFYHOST 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_SSL_VERIFYHOST \- verify the certificate\(aqs name against host
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYHOST, long verify);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long set to 2L to make libcurl verify the host in the server\(aqs TLS
  12. certificate.
  13. When negotiating a TLS connection, the server sends a certificate indicating
  14. its identity.
  15. When \fICURLOPT_SSL_VERIFYHOST(3)\fP is set to 1 or 2, the server certificate must
  16. indicate that it was made for the hostname or address curl connects to, or the
  17. connection fails. Simply put, it means it has to have the same name in the
  18. certificate as is used in the URL you operate against.
  19. curl considers the server the intended one when the Common Name field or a
  20. Subject Alternate Name field in the certificate matches the hostname in the
  21. URL to which you told curl to connect.
  22. When the \fIverify\fP value is 0, the connection succeeds regardless of the names
  23. in the certificate. Use that ability with caution,
  24. This option controls checking the server\(aqs certificate\(aqs claimed identity. The
  25. separate \fICURLOPT_SSL_VERIFYPEER(3)\fP options enables/disables verification that
  26. the certificate is signed by a trusted Certificate Authority.
  27. WARNING: disabling verification of the certificate allows bad guys to
  28. man\-in\-the\-middle the communication without you knowing it. Disabling
  29. verification makes the communication insecure. Just having encryption on a
  30. transfer is not enough as you cannot be sure that you are communicating with
  31. the correct end\-point.
  32. When libcurl uses secure protocols it trusts responses and allows for example
  33. HSTS and Alt\-Svc information to be stored and used subsequently. Disabling
  34. certificate verification can make libcurl trust and use such information from
  35. malicious servers.
  36. .SH MATCHING
  37. A certificate can have the name as a wildcard. The only asterisk (\fI*\fP) must
  38. then be the left\-most character and it must be followed by a period. The
  39. wildcard must further contain more than one period as it cannot be set for a
  40. top\-level domain.
  41. A certificate can be set for a numerical IP address (IPv4 or IPv6), but then
  42. it should be a Subject Alternate Name kind and its type should correctly
  43. identify the field as an IP address.
  44. .SH LIMITATIONS
  45. Secure Transport: If \fIverify\fP value is 0, then SNI is also disabled. SNI is a
  46. TLS extension that sends the hostname to the server. The server may use that
  47. information to do such things as sending back a specific certificate for the
  48. hostname, or forwarding the request to a specific origin server. Some
  49. hostnames may be inaccessible if SNI is not sent.
  50. .SH DEFAULT
  51. 2
  52. .SH PROTOCOLS
  53. This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
  54. All TLS backends support this option.
  55. .SH EXAMPLE
  56. .nf
  57. int main(void)
  58. {
  59. CURL *curl = curl_easy_init();
  60. if(curl) {
  61. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  62. /* Set the default value: strict name check please */
  63. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
  64. curl_easy_perform(curl);
  65. }
  66. }
  67. .fi
  68. .SH AVAILABILITY
  69. Added in curl 7.8.1
  70. .SH HISTORY
  71. In 7.28.0 and earlier: the value 1 was treated as a debug option of some
  72. sorts, not supported anymore due to frequently leading to programmer mistakes.
  73. From 7.28.1 to 7.65.3: setting it to 1 made \fIcurl_easy_setopt(3)\fP return
  74. an error and leaving the flag untouched.
  75. From 7.66.0: libcurl treats 1 and 2 to this option the same.
  76. .SH RETURN VALUE
  77. Returns CURLE_OK if TLS is supported, and CURLE_UNKNOWN_OPTION if not.
  78. .SH SEE ALSO
  79. .BR CURLOPT_CAINFO (3),
  80. .BR CURLOPT_PINNEDPUBLICKEY (3),
  81. .BR CURLOPT_SSL_VERIFYPEER (3)