CURLOPT_KEYPASSWD(3)
π CURLOPT_KEYPASSWD β passphrase to private key π
okay bestie, this is a page from the libcurl manual (the Library Functions Manual, no less π) and it's about handing curl the little secret password for your private key. let's get into it β¨
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_KEYPASSWD, char *pwd);
that's the whole vibe check right there π«Ά
πΈ DESCRIPTION πΈ
so you pass a pointer to a null-terminated string as the parameter, right? and that string is literally just the password required to use the CURLOPT_SSLKEY(3) or CURLOPT_SSH_PRIVATE_KEYFILE(3) private key π
big mood clarification incoming: you never need a passphrase to load a certificate, but you do need one to load your private key. that's just how it is, no cap π
the good news? the application does not have to keep the string around after setting this option. so like, you can let it go, it's fine, it's handled β¨
also!! if you use this option multiple times, the last set string overrides all the previous ones β last one wins, main character energy π and if you set it to NULL you can disable its use again. easy.
π DEFAULT π
NULL
like, nothing, nada, zero passphrase by default π
π¦ PROTOCOLS π¦
this functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. literally the whole secure squad π
and ngl, this option works only with the following TLS backends:
- OpenSSL
- Schannel
- mbedTLS
- wolfSSL
those four, that's the list, periodt π
π₯ EXAMPLE π₯
here's the little demo, keep it exact bestie:
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "superman");
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
look at that, cert + key + passphrase, all set up, ate and left no crumbs π
π HISTORY π
okay so this option has had a few names, glow-up era:
- it was known as
CURLOPT_SSLKEYPASSWDup to 7.16.4 - and as
CURLOPT_SSLCERTPASSWDup to 7.9.2
iconic rebranding honestly π
β AVAILABILITY β
Added in curl 7.17.0 β¨ (yes, it's been around, it's a veteran π )
π§ RETURN VALUE π§
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK(0) means everything was OK, slay π- non-zero means an error occurred β see
libcurl-errors(3)for the deets π
π SEE ALSO π
go read those too, they're besties with this page π«Ά
lowkey reminder: passphrase = for the private key, not the certificate. don't mix them up bestie π
and that's the page!! brought to you by libcurl, dated 2026-10-12, and originally filed under CURLOPT_KEYPASSWD(3) β mwah, go secure those keys ππ
β¨
π¦ 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