GNURLOPT_KEYPASSWD(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

✨ GNURLOPT_KEYPASSWD(3) ✨

okay so bestie, welcome to the GNURLOPT_KEYPASSWD page πŸ’… β€” this one lives in the curl_easy_setopt options manual, and honestly? it's giving "small but mighty". it's all about handing curl the passphrase for your private key. no cap, you're gonna want this one ✨


πŸŽ€ NAME πŸŽ€

CURLOPT_KEYPASSWD β€” set passphrase to private key πŸ”‘

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_KEYPASSWD, char *pwd);

πŸ’– DESCRIPTION πŸ’–

so basically, you pass a pointer to a null-terminated string as the parameter, and that string is literally the password required to use your CURLOPT_SSLKEY(3) or CURLOPT_SSH_PRIVATE_KEYFILE(3) private key πŸ”₯

the glow-up explanation: you never needed a pass phrase to load a certificate, but you do need one to load your private key. that's just how it is, periodt πŸ’…

and the good news β€” the application does not have to keep the string around after setting this option 🫢 set it and forget it, icon behavior.

🌸 DEFAULT 🌸

NULL

🧚 PROTOCOLS 🧚

all the TLS based protocols, bestie: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. 🌈 like, the whole secure squad.

⭐ EXAMPLE ⭐

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://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");
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

not the passphrase being "superman" 😭 main character energy fr fr. anyway β€” copy this exactly, don't get cute with it.

πŸ‘‘ AVAILABILITY πŸ‘‘

history lesson, bestie, and it's kind of a name-change arc πŸ’€:

  • this option was known as CURLOPT_SSLKEYPASSWD up to 7.16.4
  • and also as CURLOPT_SSLCERTPASSWD up to 7.9.2

so if you're reading ancient code and see those old names? that's the same girl, different era πŸ’œ

πŸ”₯ RETURN VALUE πŸ”₯

  • CURLE_OK β€” if TLS enabled, slay βœ…
  • CURLE_UNKNOWN_OPTION β€” if not, oop πŸ™ˆ
  • CURLE_OUT_OF_MEMORY β€” if there was insufficient heap space 😭

πŸ’œ SEE ALSO πŸ’œ


⚠️ friendly reminder that this is the passphrase for your private key β€” treat it like a secret, because it literally is one 🫢

and that's the whole page, bestie πŸŽ€ this one came from libcurl 7.37.0, dated 17 Jun 2014 β€” vintage but still iconic ✨ mwah πŸ’‹

πŸ“¦ where this page comes from