CURLOPT_DOH_URL.md (2687B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_DOH_URL 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_DNS_CACHE_TIMEOUT (3) 9 - CURLOPT_RESOLVE (3) 10 - CURLOPT_VERBOSE (3) 11 Protocol: 12 - All 13 Added-in: 7.62.0 14 --- 15 16 # NAME 17 18 CURLOPT_DOH_URL - provide the DNS-over-HTTPS URL 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_URL, char *URL); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass in a pointer to a *URL* for the DoH server to use for name resolving. The 31 parameter should be a char pointer to a null-terminated string which must be a 32 valid and correct HTTPS URL. 33 34 libcurl does not validate the syntax or use this variable until the transfer 35 is issued. Even if you set a crazy value here, curl_easy_setopt(3) still 36 returns *CURLE_OK*. 37 38 curl sends POST requests to the given DNS-over-HTTPS URL. 39 40 To find the DoH server itself, which might be specified using a name, libcurl 41 uses the default name lookup function. You can bootstrap that by providing the 42 address for the DoH server with CURLOPT_RESOLVE(3). 43 44 The application does not have to keep the string around after setting this 45 option. 46 47 Using this option multiple times makes the last set string override the 48 previous ones. Set it to NULL to disable its use again. 49 50 # INHERIT OPTIONS 51 52 DoH lookups use SSL and some SSL settings from your transfer are inherited, 53 like CURLOPT_SSL_CTX_FUNCTION(3). 54 55 The hostname and peer certificate verification settings are not inherited but 56 can be controlled separately via CURLOPT_DOH_SSL_VERIFYHOST(3) and 57 CURLOPT_DOH_SSL_VERIFYPEER(3). 58 59 A set CURLOPT_OPENSOCKETFUNCTION(3) callback is not inherited. 60 61 # KNOWN BUGS 62 63 Even when DoH is set to be used with this option, there are still some name 64 resolves that are performed without it, using the default name resolver 65 mechanism. This includes name resolves done for CURLOPT_INTERFACE(3), 66 CURLOPT_FTPPORT(3), a proxy type set to **CURLPROXY_SOCKS4** or 67 **CURLPROXY_SOCKS5** and probably some more. 68 69 # DEFAULT 70 71 NULL 72 73 # %PROTOCOLS% 74 75 # EXAMPLE 76 77 ~~~c 78 int main(void) 79 { 80 CURL *curl = curl_easy_init(); 81 if(curl) { 82 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 83 curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://dns.example.com"); 84 curl_easy_perform(curl); 85 } 86 } 87 ~~~ 88 89 # %AVAILABILITY% 90 91 # RETURN VALUE 92 93 curl_easy_setopt(3) returns a CURLcode indicating success or error. 94 95 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 96 libcurl-errors(3). 97 98 Note that curl_easy_setopt(3) does immediately parse the given string so when 99 given a bad DoH URL, libcurl might not detect the problem until it later tries 100 to resolve a name with it.