CURLOPT_DOH_SSL_VERIFYPEER.md (3113B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_DOH_SSL_VERIFYPEER 5 Section: 3 6 Source: libcurl 7 See-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 Protocol: 16 - TLS 17 TLS-backend: 18 - All 19 Added-in: 7.76.0 20 --- 21 22 # NAME 23 24 CURLOPT_DOH_SSL_VERIFYPEER - verify the DoH SSL certificate 25 26 # SYNOPSIS 27 28 ~~~c 29 #include <curl/curl.h> 30 31 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_SSL_VERIFYPEER, 32 long verify); 33 ~~~ 34 35 # DESCRIPTION 36 37 Pass a long as parameter set to 1L to enable or 0L to disable. 38 39 This option tells curl to verify the authenticity of the DoH (DNS-over-HTTPS) 40 server's certificate. A value of 1 means curl verifies; 0 (zero) means it 41 does not. 42 43 This option is the DoH equivalent of CURLOPT_SSL_VERIFYPEER(3) and 44 only affects requests to the DoH server. 45 46 When negotiating a TLS or SSL connection, the server sends a certificate 47 indicating its identity. curl verifies whether the certificate is authentic, 48 i.e. that you can trust that the server is who the certificate says it is. 49 This trust is based on a chain of digital signatures, rooted in certification 50 authority (CA) certificates you supply. curl uses a default bundle of CA 51 certificates (the path for that is determined at build time) and you can 52 specify alternate certificates with the CURLOPT_CAINFO(3) option or the 53 CURLOPT_CAPATH(3) option. 54 55 When CURLOPT_DOH_SSL_VERIFYPEER(3) is enabled, and the verification fails to 56 prove that the certificate is authentic, the connection fails. When the option 57 is zero, the peer certificate verification succeeds regardless. 58 59 Authenticating the certificate is not enough to be sure about the server. You 60 typically also want to ensure that the server is the server you mean to be 61 talking to. Use CURLOPT_DOH_SSL_VERIFYHOST(3) for that. The check that the 62 hostname in the certificate is valid for the hostname you are connecting to 63 is done independently of the CURLOPT_DOH_SSL_VERIFYPEER(3) option. 64 65 WARNING: disabling verification of the certificate allows bad guys to 66 man-in-the-middle the communication without you knowing it. Disabling 67 verification makes the communication insecure. Just having encryption on a 68 transfer is not enough as you cannot be sure that you are communicating with 69 the correct end-point. 70 71 # DEFAULT 72 73 1 74 75 # %PROTOCOLS% 76 77 # EXAMPLE 78 79 ~~~c 80 int 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 101 curl_easy_setopt(3) returns a CURLcode indicating success or error. 102 103 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 104 libcurl-errors(3).