1CURLOPT_SSL_VERIFYHOST(3)  curl_easy_setopt options  CURLOPT_SSL_VERIFYHOST(3)
2
3
4

NAME

6       CURLOPT_SSL_VERIFYHOST - verify the certificate's name against host
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYHOST, long verify);
12

DESCRIPTION

14       Pass a long as parameter specifying what to verify.
15
16       This option determines whether libcurl verifies that the server cert is
17       for the server it is known as.
18
19       When negotiating TLS and SSL connections, the server sends  a  certifi‐
20       cate indicating its identity.
21
22       When  CURLOPT_SSL_VERIFYHOST(3)  is  2,  that certificate must indicate
23       that the server is the server to which you meant  to  connect,  or  the
24       connection  fails. Simply put, it means it has to have the same name in
25       the certificate as is in the URL you operate against.
26
27       Curl considers the server the intended one when the Common  Name  field
28       or  a  Subject Alternate Name field in the certificate matches the host
29       name in the URL to which you told Curl to connect.
30
31       If verify value is set to 1:
32
33       In 7.28.0 and earlier: treated as a debug option  of  some  sorts,  not
34       supported anymore due to frequently leading to programmer mistakes.
35
36       From  7.28.1  to 7.65.3: setting it to 1 made curl_easy_setopt() return
37       an error and leaving the flag untouched.
38
39       From 7.66.0: treats 1 and 2 the same.
40
41       When the verify value is 0, the connection succeeds regardless  of  the
42       names in the certificate. Use that ability with caution!
43
44       The default value for this option is 2.
45
46       This  option controls checking the server's certificate's claimed iden‐
47       tity.   The  server  could  be  lying.   To  control  lying,  see  CUR‐
48       LOPT_SSL_VERIFYPEER(3).
49
50       WARNING:  disabling  verification of the certificate allows bad guys to
51       man-in-the-middle the communication without you knowing  it.  Disabling
52       verification  makes  the communication insecure. Just having encryption
53       on a transfer is not enough as you cannot be sure that you are communi‐
54       cating with the correct end-point.
55
56       When  libcurl  uses secure protocols it trusts responses and allows for
57       example HSTS and Alt-Svc information  to  be  stored  and  used  subse‐
58       quently.  Disabling certificate verification can make libcurl trust and
59       use such information from malicious servers.
60

LIMITATIONS

62       Secure Transport: If verify value is 0, then SNI is also disabled.  SNI
63       is  a  TLS  extension that sends the hostname to the server. The server
64       may use that information to do such things as sending back  a  specific
65       certificate  for  the hostname, or forwarding the request to a specific
66       origin server. Some hostnames may be inaccessible if SNI is not sent.
67
68       NSS: If CURLOPT_SSL_VERIFYPEER(3) is zero, CURLOPT_SSL_VERIFYHOST(3) is
69       also set to zero and cannot be overridden.
70

DEFAULT

72       2
73

PROTOCOLS

75       All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
76

EXAMPLE

78       CURL *curl = curl_easy_init();
79       if(curl) {
80         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
81
82         /* Set the default value: strict name check please */
83         curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
84
85         curl_easy_perform(curl);
86       }
87

AVAILABILITY

89       If built TLS enabled.
90

RETURN VALUE

92       Returns CURLE_OK if TLS is supported, and CURLE_UNKNOWN_OPTION if not.
93
94       If 1 is set as argument, CURLE_BAD_FUNCTION_ARGUMENT is returned.
95

SEE ALSO

97       CURLOPT_SSL_VERIFYPEER(3), CURLOPT_CAINFO(3),
98
99
100
101libcurl 8.0.1                  January 02, 2023      CURLOPT_SSL_VERIFYHOST(3)
Impressum