xref: /curl/docs/libcurl/opts/CURLOPT_USE_SSL.md (revision 5a488251)
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
16Added-in: 7.17.0
17---
18
19# NAME
20
21CURLOPT_USE_SSL - request using SSL / TLS for the transfer
22
23# SYNOPSIS
24
25~~~c
26#include <curl/curl.h>
27
28CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USE_SSL, long level);
29~~~
30
31# DESCRIPTION
32
33Pass a long using one of the values from below, to make libcurl use your
34desired *level* of SSL for the transfer.
35
36These are all protocols that start out plain text and get "upgraded" to SSL
37using the STARTTLS command.
38
39This is for enabling SSL/TLS when you use FTP, SMTP, POP3, IMAP etc.
40
41## CURLUSESSL_NONE
42
43do not attempt to use SSL.
44
45## CURLUSESSL_TRY
46
47Try using SSL, proceed as normal otherwise. Note that server may close the
48connection if the negotiation does not succeed.
49
50## CURLUSESSL_CONTROL
51
52Require SSL for the control connection or fail with *CURLE_USE_SSL_FAILED*.
53
54## CURLUSESSL_ALL
55
56Require SSL for all communication or fail with *CURLE_USE_SSL_FAILED*.
57
58# DEFAULT
59
60CURLUSESSL_NONE
61
62# %PROTOCOLS%
63
64# EXAMPLE
65
66~~~c
67int 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
84This option was known as CURLOPT_FTP_SSL up to 7.16.4, and the constants were
85known as CURLFTPSSL_* Handled by LDAP since 7.81.0. Fully supported by the
86OpenLDAP backend only.
87
88# %AVAILABILITY%
89
90# RETURN VALUE
91
92Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
93