GNURLOPT_SSLKEY_BLOB(3)
π GNURLOPT_SSLKEY_BLOB β the manual page, but make it make sense
okay so this is a page from the gnurl manual (the curl_easy_setopt options corner of it, to be exact) and bestie, it's all about handing libcurl your private key straight from memory instead of making it go dig around in your filesystem. obsessed. let's get into it π«Ά
β¨ NAME β¨
CURLOPT_SSLKEY_BLOB β literally just: the private key for your client cert, but coming at you from a memory blob π
πΈ SYNOPSIS πΈ
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY_BLOB,
struct curl_blob *blob);
π¦ DESCRIPTION π¦
So you pass in a pointer to a curl_blob structure, and that struct is carrying the info for a private key β as in, a pointer and a size, the whole package π. This one is compatible with OpenSSL. And the format (like "PEM") has to be specified with CURLOPT_SSLKEYTYPE(3) β no guessing games, you have to tell it.
Here's the cute part: if the blob is initialized with the flags member of struct curl_blob set to CURL_BLOB_COPY, then the application does not have to keep the buffer around after setting this. it made its own copy, you're free ποΈ
This option is an alternative to CURLOPT_SSLKEY(3), which instead expects a file name as input. same energy, different delivery method fr fr.
π DEFAULT π
NULL
(nothing's set until you set it, iconic behavior)
π PROTOCOLS π
All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. β the whole secure squad π
β EXAMPLE β
CURL *curl = curl_easy_init();
if(curl) {
struct curl_blob blob;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
blob.data = certificateData;
blob.len = filesize;
blob.flags = CURL_BLOB_COPY;
curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &blob);
curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
blob.data = privateKeyData;
blob.len = privateKeySize;
curl_easy_setopt(curl, CURLOPT_SSLKEY_BLOB, &blob);
curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM");
ret = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
like, look at it. cert blob, key blob, password "s3cret", type "PEM", done. main character energy honestly π₯
π§ AVAILABILITY π§
Added in libcurl 7.71.0. This option is supported by the OpenSSL backends.
π RETURN VALUE π
- Returns
CURLE_OKif TLS enabled CURLE_UNKNOWN_OPTIONif not- or
CURLE_OUT_OF_MEMORYif there was insufficient heap space π (heap said no π)
π₯ SEE ALSO π₯
ngl bestie, read those two too β they're the supporting cast and they ate π
okay that's the whole page!! no cap, you got this π
β with love, from libcurl 7.71.0, dated 24 Jun 2020 (yes that's the version and the date, i would never gatekeep a citation from you) πβ¨
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms