1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_SSL_VERIFYHOST 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_CAINFO (3) 9 - CURLOPT_PINNEDPUBLICKEY (3) 10 - CURLOPT_SSL_VERIFYPEER (3) 11Protocol: 12 - TLS 13TLS-backend: 14 - All 15--- 16 17# NAME 18 19CURLOPT_SSL_VERIFYHOST - verify the certificate's name against host 20 21# SYNOPSIS 22 23~~~c 24#include <curl/curl.h> 25 26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYHOST, long verify); 27~~~ 28 29# DESCRIPTION 30 31Pass a long as parameter specifying what to *verify*. 32 33This option determines whether libcurl verifies that the server cert is for 34the server it is known as. 35 36When negotiating TLS and SSL connections, the server sends a certificate 37indicating its identity. 38 39When CURLOPT_SSL_VERIFYHOST(3) is 2, that certificate must indicate that 40the server is the server to which you meant to connect, or the connection 41fails. Simply put, it means it has to have the same name in the certificate as 42is in the URL you operate against. 43 44Curl considers the server the intended one when the Common Name field or a 45Subject Alternate Name field in the certificate matches the hostname in the 46URL to which you told Curl to connect. 47 48If *verify* value is set to 1: 49 50In 7.28.0 and earlier: treated as a debug option of some sorts, not supported 51anymore due to frequently leading to programmer mistakes. 52 53From 7.28.1 to 7.65.3: setting it to 1 made curl_easy_setopt(3) return 54an error and leaving the flag untouched. 55 56From 7.66.0: treats 1 and 2 the same. 57 58When the *verify* value is 0, the connection succeeds regardless of the 59names in the certificate. Use that ability with caution! 60 61The default value for this option is 2. 62 63This option controls checking the server's certificate's claimed identity. 64The server could be lying. To control lying, see CURLOPT_SSL_VERIFYPEER(3). 65 66WARNING: disabling verification of the certificate allows bad guys to 67man-in-the-middle the communication without you knowing it. Disabling 68verification makes the communication insecure. Just having encryption on a 69transfer is not enough as you cannot be sure that you are communicating with 70the correct end-point. 71 72When libcurl uses secure protocols it trusts responses and allows for example 73HSTS and Alt-Svc information to be stored and used subsequently. Disabling 74certificate verification can make libcurl trust and use such information from 75malicious servers. 76 77# LIMITATIONS 78 79Secure Transport: If *verify* value is 0, then SNI is also disabled. SNI is 80a TLS extension that sends the hostname to the server. The server may use that 81information to do such things as sending back a specific certificate for the 82hostname, or forwarding the request to a specific origin server. Some hostnames 83may be inaccessible if SNI is not sent. 84 85# DEFAULT 86 872 88 89# EXAMPLE 90 91~~~c 92int main(void) 93{ 94 CURL *curl = curl_easy_init(); 95 if(curl) { 96 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 97 98 /* Set the default value: strict name check please */ 99 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); 100 101 curl_easy_perform(curl); 102 } 103} 104~~~ 105 106# AVAILABILITY 107 108If built TLS enabled. 109 110# RETURN VALUE 111 112Returns CURLE_OK if TLS is supported, and CURLE_UNKNOWN_OPTION if not. 113 114If 1 is set as argument, *CURLE_BAD_FUNCTION_ARGUMENT* is returned. 115