1--- 2c: Copyright (C) Daniel Stenberg, <daniel.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) 15--- 16 17# NAME 18 19CURLOPT_DOH_SSL_VERIFYPEER - verify the DoH SSL certificate 20 21# SYNOPSIS 22 23~~~c 24#include <curl/curl.h> 25 26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_SSL_VERIFYPEER, 27 long verify); 28~~~ 29 30# DESCRIPTION 31 32Pass a long as parameter set to 1L to enable or 0L to disable. 33 34This option tells curl to verify the authenticity of the DoH (DNS-over-HTTPS) 35server's certificate. A value of 1 means curl verifies; 0 (zero) means it 36does not. 37 38This option is the DoH equivalent of CURLOPT_SSL_VERIFYPEER(3) and 39only affects requests to the DoH server. 40 41When negotiating a TLS or SSL connection, the server sends a certificate 42indicating its identity. Curl verifies whether the certificate is authentic, 43i.e. that you can trust that the server is who the certificate says it is. 44This trust is based on a chain of digital signatures, rooted in certification 45authority (CA) certificates you supply. curl uses a default bundle of CA 46certificates (the path for that is determined at build time) and you can 47specify alternate certificates with the CURLOPT_CAINFO(3) option or the 48CURLOPT_CAPATH(3) option. 49 50When CURLOPT_DOH_SSL_VERIFYPEER(3) is enabled, and the verification fails to 51prove that the certificate is authentic, the connection fails. When the option 52is zero, the peer certificate verification succeeds regardless. 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_DOH_SSL_VERIFYHOST(3) for that. The check that the 57hostname in the certificate is valid for the hostname you are connecting to 58is done independently of the CURLOPT_DOH_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 66# DEFAULT 67 681 69 70# PROTOCOLS 71 72DoH 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