curl_easy_ssls_import(3)
π curl_easy_ssls_import β like, the "import SSL sessions" page π
okay bestie, welcome to the libcurl section of the manual (yes, that's the manual name, we're being official now β¨). This is curl_easy_ssls_import(3) and it's honestly kinda iconic: it's the little function that lets you bring an SSL session back home.
β¨ NAME β¨
curl_easy_ssls_import β import SSL sessions π like, re-import them, the ones you exported earlier, no cap
π¦ SYNOPSIS π¦
#include <curl/curl.h>
CURLcode curl_easy_ssls_import(CURL *handle,
const char *session_key,
const unsigned char *shmac, size_t shmac_len,
const unsigned char *sdata, size_t sdata_len);
πΈ DESCRIPTION πΈ
So here's the vibe π«Ά: this function imports a previously exported SSL session ticket. That's it, that's the whole personality.
The tea β: sdata and sdata_len must always be provided. Non-negotiable, periodt. But if session_key is NULL, then shmac and shmac_len must be given exactly as they were received during the export. Curious about what those even are? Go peek at curl_easy_ssls_export(3) β it describes them properly, iykyk.
β οΈ Lowkey important: importing session tickets from other curl versions may fail, because the handling ofshmacorsdatacan change between versions. Not a bug, just how it is π.
And if a session ticket has already expired? It gets silently discarded. No error, no drama, it just β¨ evaporates β¨. Very main character energy honestly.
π PROTOCOLS π
This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. The whole squad π.
This option works only with the following TLS backends: GnuTLS, OpenSSL, mbedTLS and wolfSSL. Those four, no substitutes π.
π EXAMPLE π
Here's the whole thing in action, copy-paste ready, bestie:
int main(void)
{
CURLSHcode sh;
CURLSH *share = curl_share_init();
CURLcode result;
CURL *curl;
sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
if(sh)
printf("Error: %s\n", curl_share_strerror(sh));
curl = curl_easy_init();
if(curl) {
extern unsigned char *shmac, *sdata;
size_t hlen = 4, slen = 5;
curl_easy_setopt(curl, CURLOPT_SHARE, share);
/* read shmac and sdata from storage */
result = curl_easy_ssls_import(curl, NULL, shmac, hlen, sdata, slen);
/* always cleanup */
curl_easy_cleanup(curl);
}
curl_share_cleanup(share);
}
Notice the /* read shmac and sdata from storage */ comment β that's you, that's your job, curl isn't gonna fetch those for you π.
β AVAILABILITY β
Added in curl 8.12.0 β so if you're on something ancient, this is your sign to upgrade π§
π₯ RETURN VALUE π₯
This function returns a CURLcode indicating success or error.
CURLE_OK(0) means everything was, like, totally fine π- non-zero means an error occurred β go check
libcurl-errors(3)for the full lore
And here's a handy tip π: if CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3), there can be an error message stored in the error buffer when non-zero is returned. So you might get actual words explaining the problem, which is honestly so thoughtful of it.
π SEE ALSO π
π real talk: keep yoursdataandsdata_lenaround, keep yourshmacmatching the export ifsession_keyisNULL, and don't expect expired tickets to do anything but ghost you.
okay that's the whole page, bestie, you ate that ππ β this was libcurl, dated 2026-10-12, and the page you just read is curl_easy_ssls_import(3). mwah π
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms