1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.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)
14Protocol:
15  - TLS
16TLS-backend:
17  - All
18---
19
20# NAME
21
22CURLOPT_SSL_VERIFYPEER - verify the peer's SSL certificate
23
24# SYNOPSIS
25
26~~~c
27#include <curl/curl.h>
28
29CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYPEER, long verify);
30~~~
31
32# DESCRIPTION
33
34Pass a long as parameter to enable or disable.
35
36This option determines whether curl verifies the authenticity of the peer's
37certificate. A value of 1 means curl verifies; 0 (zero) means it does not.
38
39When negotiating a TLS or SSL connection, the server sends a certificate
40indicating its identity. Curl verifies whether the certificate is authentic,
41i.e. that you can trust that the server is who the certificate says it is.
42This trust is based on a chain of digital signatures, rooted in certification
43authority (CA) certificates you supply. curl uses a default bundle of CA
44certificates (the path for that is determined at build time) and you can
45specify alternate certificates with the CURLOPT_CAINFO(3) option or the
46CURLOPT_CAPATH(3) option.
47
48When CURLOPT_SSL_VERIFYPEER(3) is enabled, and the verification fails to
49prove that the certificate is signed by a CA, the connection fails.
50
51When this option is disabled (set to zero), the CA certificates are not loaded
52and the peer certificate verification is simply skipped.
53
54Authenticating the certificate is not enough to be sure about the server. You
55typically also want to ensure that the server is the server you mean to be
56talking to. Use CURLOPT_SSL_VERIFYHOST(3) for that. The check that the host
57name in the certificate is valid for the hostname you are connecting to is
58done independently of the CURLOPT_SSL_VERIFYPEER(3) option.
59
60WARNING: disabling verification of the certificate allows bad guys to
61man-in-the-middle the communication without you knowing it. Disabling
62verification makes the communication insecure. Just having encryption on a
63transfer is not enough as you cannot be sure that you are communicating with
64the correct end-point.
65
66When libcurl uses secure protocols it trusts responses and allows for example
67HSTS and Alt-Svc information to be stored and used subsequently. Disabling
68certificate verification can make libcurl trust and use such information from
69malicious servers.
70
71# DEFAULT
72
731 - enabled
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