1CURLOPT_SSL_VERIFYHOST(3) curl_easy_setopt options CURLOPT_SSL_VERIFYHOST(3)
2
3
4
6 CURLOPT_SSL_VERIFYHOST - verify the certificate's name against host
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYHOST, long
12 verify);
13
15 Pass a long as parameter specifying what to verify.
16
17 This option determines whether libcurl verifies that the server cert is
18 for the server it is known as.
19
20 When negotiating TLS and SSL connections, the server sends a certifi‐
21 cate indicating its identity.
22
23 When CURLOPT_SSL_VERIFYHOST(3) is 2, that certificate must indicate
24 that the server is the server to which you meant to connect, or the
25 connection fails. Simply put, it means it has to have the same name in
26 the certificate as is in the URL you operate against.
27
28 Curl considers the server the intended one when the Common Name field
29 or a Subject Alternate Name field in the certificate matches the host
30 name in the URL to which you told Curl to connect.
31
32 If verify value is set to 1:
33
34 In 7.28.0 and earlier: treated as a debug option of some sorts, not
35 supported anymore due to frequently leading to programmer mistakes.
36
37 From 7.28.1 to 7.65.3: setting it to 1 made curl_easy_setopt() return
38 an error and leaving the flag untouched.
39
40 From 7.66.0: treats 1 and 2 the same.
41
42 When the verify value is 0, the connection succeeds regardless of the
43 names in the certificate. Use that ability with caution!
44
45 The default value for this option is 2.
46
47 This option controls checking the server's certificate's claimed iden‐
48 tity. The server could be lying. To control lying, see CUR‐
49 LOPT_SSL_VERIFYPEER(3).
50
52 Secure Transport: If verify value is 0, then SNI is also disabled. SNI
53 is a TLS extension that sends the hostname to the server. The server
54 may use that information to do such things as sending back a specific
55 certificate for the hostname, or forwarding the request to a specific
56 origin server. Some hostnames may be inaccessible if SNI is not sent.
57
58 NSS: If CURLOPT_SSL_VERIFYPEER(3) is zero, CURLOPT_SSL_VERIFYHOST(3) is
59 also set to zero and cannot be overridden.
60
62 2
63
65 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
66
68 CURL *curl = curl_easy_init();
69 if(curl) {
70 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
71
72 /* Set the default value: strict name check please */
73 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
74
75 curl_easy_perform(curl);
76 }
77
79 If built TLS enabled.
80
82 Returns CURLE_OK if TLS is supported, and CURLE_UNKNOWN_OPTION if not.
83
84 If 1 is set as argument, CURLE_BAD_FUNCTION_ARGUMENT is returned.
85
87 CURLOPT_SSL_VERIFYPEER(3), CURLOPT_CAINFO(3),
88
89
90
91libcurl 7.76.1 November 04, 2020 CURLOPT_SSL_VERIFYHOST(3)