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