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