CURLOPT_USE_SSL.md (1905B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_USE_SSL 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_PROXY_SSLVERSION (3) 9 - CURLOPT_SSLVERSION (3) 10 - CURLOPT_SSL_OPTIONS (3) 11 Protocol: 12 - FTP 13 - SMTP 14 - POP3 15 - IMAP 16 Added-in: 7.17.0 17 --- 18 19 # NAME 20 21 CURLOPT_USE_SSL - request using SSL / TLS for the transfer 22 23 # SYNOPSIS 24 25 ~~~c 26 #include <curl/curl.h> 27 28 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USE_SSL, long level); 29 ~~~ 30 31 # DESCRIPTION 32 33 Pass a long using one of the values from below, to make libcurl use your 34 desired *level* of SSL for the transfer. 35 36 These are all protocols that start out plain text and get "upgraded" to SSL 37 using the STARTTLS command. 38 39 This is for enabling SSL/TLS when you use FTP, SMTP, POP3, IMAP etc. 40 41 ## CURLUSESSL_NONE 42 43 do not attempt to use SSL. 44 45 ## CURLUSESSL_TRY 46 47 Try using SSL, proceed as normal otherwise. Note that server may close the 48 connection if the negotiation does not succeed. 49 50 ## CURLUSESSL_CONTROL 51 52 Require SSL for the control connection or fail with *CURLE_USE_SSL_FAILED*. 53 54 ## CURLUSESSL_ALL 55 56 Require SSL for all communication or fail with *CURLE_USE_SSL_FAILED*. 57 58 # DEFAULT 59 60 CURLUSESSL_NONE 61 62 # %PROTOCOLS% 63 64 # EXAMPLE 65 66 ~~~c 67 int main(void) 68 { 69 CURL *curl = curl_easy_init(); 70 if(curl) { 71 curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/file.ext"); 72 73 /* require use of SSL for this, or fail */ 74 curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL); 75 76 /* Perform the request */ 77 curl_easy_perform(curl); 78 } 79 } 80 ~~~ 81 82 # HISTORY 83 84 This option was known as CURLOPT_FTP_SSL up to 7.16.4. Supported by LDAP since 85 7.81.0. Fully supported by the OpenLDAP backend only. 86 87 # %AVAILABILITY% 88 89 # RETURN VALUE 90 91 curl_easy_setopt(3) returns a CURLcode indicating success or error. 92 93 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 94 libcurl-errors(3).