CURLOPT_SOCKS5_AUTH.md (1595B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_SOCKS5_AUTH 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_PROXY (3) 9 - CURLOPT_PROXYTYPE (3) 10 Protocol: 11 - All 12 Added-in: 7.55.0 13 --- 14 15 # NAME 16 17 CURLOPT_SOCKS5_AUTH - methods for SOCKS5 proxy authentication 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKS5_AUTH, long bitmask); 25 ~~~ 26 27 # DESCRIPTION 28 29 Pass a long as parameter, which is set to a bitmask, to tell libcurl which 30 authentication method(s) are allowed for SOCKS5 proxy authentication. The only 31 supported flags are *CURLAUTH_BASIC*, which allows username/password 32 authentication, *CURLAUTH_GSSAPI*, which allows GSS-API authentication, and 33 *CURLAUTH_NONE*, which allows no authentication. Set the actual username and 34 password with the CURLOPT_PROXYUSERPWD(3) option. 35 36 # DEFAULT 37 38 CURLAUTH_BASIC|CURLAUTH_GSSAPI 39 40 # %PROTOCOLS% 41 42 # EXAMPLE 43 44 ~~~c 45 int main(void) 46 { 47 CURL *curl = curl_easy_init(); 48 if(curl) { 49 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 50 51 /* request to use a SOCKS5 proxy */ 52 curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://user:pass@myproxy.com"); 53 54 /* enable username/password authentication only */ 55 curl_easy_setopt(curl, CURLOPT_SOCKS5_AUTH, (long)CURLAUTH_BASIC); 56 57 /* Perform the request */ 58 curl_easy_perform(curl); 59 } 60 } 61 ~~~ 62 63 # %AVAILABILITY% 64 65 # RETURN VALUE 66 67 curl_easy_setopt(3) returns a CURLcode indicating success or error. 68 69 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 70 libcurl-errors(3).