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