CURLOPT_USE_SSL(3)

πŸ’… CURLOPT_USE_SSL(3) β€” like, the curl library functions manual, bestie πŸŽ€

okay so bestie, welcome to the CURLOPT_USE_SSL page, straight out of the curl Library Functions Manual ✨ this one is literally about telling libcurl "hey, can we do this transfer with SSL / TLS please?" πŸ¦‹


✨ NAME ✨

CURLOPT_USE_SSL β€” request using SSL / TLS for the transfer πŸ’–


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USE_SSL, long level);

πŸ’œ DESCRIPTION πŸ’œ

So what you do is you pass a long using one of the values from down below ⬇️ and that's how you make libcurl use your desired level of SSL for the transfer. main character energy tbh πŸ‘‘

these are all protocols that start out plain text and get "upgraded" to SSL using the STARTTLS command. glow-up via negotiation, iconic 🌈

this is for enabling SSL/TLS when you use FTP, SMTP, POP3, IMAP etc. iykyk πŸ’…

  • CURLUSESSL_NONE β€” do not attempt to use SSL. zero SSL, not even a little bit πŸ™ˆ
  • CURLUSESSL_TRY β€” try using SSL, proceed as normal otherwise. but bestie, heads up: the server may close the connection if the negotiation fails πŸ˜­πŸ’€
  • CURLUSESSL_CONTROL β€” require SSL for the control connection, or fail with CURLE_USE_SSL_FAILED. no SSL on that control connection? we're not doing it, periodt πŸ”₯
  • CURLUSESSL_ALL β€” require SSL for all communication, or fail with CURLE_USE_SSL_FAILED. every single bit of the convo is encrypted or we simply don't go πŸ‘‘βœ¨

πŸŽ€ DEFAULT πŸŽ€

CURLUSESSL_NONE

(the default is literally "no SSL", so yeah, you gotta ask for it fr fr πŸ’€)


πŸ¦‹ PROTOCOLS πŸ¦‹

this functionality affects ftp, imap, pop3 and smtp 🌸


⭐ EXAMPLE ⭐

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/file.ext");

    /* require use of SSL for this, or fail */
    curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);

    /* Perform the request */
    curl_easy_perform(curl);
  }
}

see how it's giving "require use of SSL for this, or fail"? that's CURLUSESSL_ALL doing its thing πŸ’…


πŸ’€ HISTORY πŸ’€

  • this option was known as CURLOPT_FTP_SSL up to 7.16.4 πŸ•°οΈ
  • supported by LDAP since 7.81.0
  • fully supported by the OpenLDAP backend only (so, like, know your backend bestie 🫢)
  • CURLUSESSL_* enums became long types in 8.13.0 β€” prior to this version a long cast was necessary when passed to curl_easy_setopt(3) 😭

🌟 AVAILABILITY 🌟

Added in curl 7.17.0 ✨


πŸ‘‘ RETURN VALUE πŸ‘‘

curl_easy_setopt(3) returns a CURLcode indicating success or error πŸ’–

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3) πŸ”


🌈 SEE ALSO 🌈


and that's the whole page bestie, go forth and negotiate your TLS πŸ§šπŸ’œ

later babes β€” this was libcurl, dated 2026-10-12, mwah πŸ’‹

πŸ“¦ where this page comes from