1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_SSL_VERIFYPEER 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_CAINFO (3) 9 - CURLINFO_CAPATH (3) 10 - CURLOPT_CAINFO (3) 11 - CURLOPT_PROXY_SSL_VERIFYHOST (3) 12 - CURLOPT_PROXY_SSL_VERIFYPEER (3) 13 - CURLOPT_SSL_VERIFYHOST (3) 14--- 15 16# NAME 17 18CURLOPT_SSL_VERIFYPEER - verify the peer's SSL certificate 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYPEER, long verify); 26~~~ 27 28# DESCRIPTION 29 30Pass a long as parameter to enable or disable. 31 32This option determines whether curl verifies the authenticity of the peer's 33certificate. A value of 1 means curl verifies; 0 (zero) means it does not. 34 35When negotiating a TLS or SSL connection, the server sends a certificate 36indicating its identity. Curl verifies whether the certificate is authentic, 37i.e. that you can trust that the server is who the certificate says it is. 38This trust is based on a chain of digital signatures, rooted in certification 39authority (CA) certificates you supply. curl uses a default bundle of CA 40certificates (the path for that is determined at build time) and you can 41specify alternate certificates with the CURLOPT_CAINFO(3) option or the 42CURLOPT_CAPATH(3) option. 43 44When CURLOPT_SSL_VERIFYPEER(3) is enabled, and the verification fails to 45prove that the certificate is signed by a CA, the connection fails. 46 47When this option is disabled (set to zero), the CA certificates are not loaded 48and the peer certificate verification is simply skipped. 49 50Authenticating the certificate is not enough to be sure about the server. You 51typically also want to ensure that the server is the server you mean to be 52talking to. Use CURLOPT_SSL_VERIFYHOST(3) for that. The check that the host 53name in the certificate is valid for the hostname you are connecting to is 54done independently of the CURLOPT_SSL_VERIFYPEER(3) option. 55 56WARNING: disabling verification of the certificate allows bad guys to 57man-in-the-middle the communication without you knowing it. Disabling 58verification makes the communication insecure. Just having encryption on a 59transfer is not enough as you cannot be sure that you are communicating with 60the correct end-point. 61 62When libcurl uses secure protocols it trusts responses and allows for example 63HSTS and Alt-Svc information to be stored and used subsequently. Disabling 64certificate verification can make libcurl trust and use such information from 65malicious servers. 66 67# DEFAULT 68 691 - enabled 70 71# PROTOCOLS 72 73All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. 74 75# EXAMPLE 76 77~~~c 78int main(void) 79{ 80 CURL *curl = curl_easy_init(); 81 if(curl) { 82 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 83 84 /* Set the default value: strict certificate check please */ 85 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); 86 87 curl_easy_perform(curl); 88 } 89} 90~~~ 91 92# AVAILABILITY 93 94If built TLS enabled. 95 96# RETURN VALUE 97 98Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 99