GNURLOPT_SSLCERT(3)
π GNURLOPT_SSLCERT(3) β set SSL client certificate π
okay so bestie, welcome to GNURLOPT_SSLCERT(3), straight out of the curl_easy_setopt options manual. This whole page is about telling curl about your SSL client certificate, and I'm gonna keep every single detail so you can absolutely slay this TLS situation. π
πΈ NAME πΈ
CURLOPT_SSLCERT - set SSL client certificate
β¨ SYNOPSIS β¨
first the include, then the function sig, no cap:
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERT, char *cert);
π¦ DESCRIPTION π¦
okay so you pass a pointer to a null-terminated string as parameter β that's the move. The string should be the file name of your client certificate. The default format is "P12" on Secure Transport and "PEM" on other engines, and can be changed with CURLOPT_SSLCERTTYPE(3). periodt.
With NSS or Secure Transport, this can also be the nickname of the certificate you wish to authenticate with as it is named in the security database. If you want to use a file from the current directory, please precede it with ./ prefix, in order to avoid confusion with a nickname. iykyk.
(Schannel only) Client certificates can be specified by a path expression to a certificate store. (You can import PFX to a store first). You can use <store location>\<store name>\<thumbprint> to refer to a certificate in the system certificates store, for example CurrentUser\MY\934a7ac6f8a5d579285a74fa61e19f23ddfe8d7a. Thumbprint is usually a SHA-1 hex string which you can see in certificate details. Following store locations are supported: CurrentUser, LocalMachine, CurrentService, Services, CurrentUserGroupPolicy, LocalMachineGroupPolicy, LocalMachineEnterprise. Schannel also support P12 certificate file, with the string "P12" specified with CURLOPT_SSLCERTTYPE(3).
When using a client certificate, you most likely also need to provide a private key with CURLOPT_SSLKEY(3). π
The application does not have to keep the string around after setting this option. π«Ά
π DEFAULT π
NULL
π PROTOCOLS π
All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. β the whole TLS friend group is invited. π
π₯ EXAMPLE π₯
here's the example, copy-paste core:
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
ret = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
β AVAILABILITY β
If built TLS enabled. β
π RETURN VALUE π
Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space. π
π«Ά SEE ALSO π«Ά
the SEE ALSO besties are CURLOPT_SSLCERTTYPE(3) and CURLOPT_SSLKEY(3) β go read those too, they're part of the lore. π«Ά
xoxo, your Unix bestie π β this page is libcurl 7.37.0, dated 17 Jun 2014, and the footer says GNURLOPT_SSLCERT(3). byeeee π«Ά
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2019, 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