CURLOPT_SSLKEY.3 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .\" generated by cd2nroff 0.1 from CURLOPT_SSLKEY.md
  2. .TH CURLOPT_SSLKEY 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_SSLKEY \- private key file for TLS and SSL client cert
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY, char *keyfile);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a null\-terminated string as parameter. The string should be
  12. the filename of your private key. The default format is "PEM" and can be
  13. changed with \fICURLOPT_SSLKEYTYPE(3)\fP.
  14. (Windows, iOS and Mac OS X) This option is ignored by Secure Transport and
  15. Schannel SSL backends because they expect the private key to be already present
  16. in the key\-chain or PKCS#12 file containing the certificate.
  17. The application does not have to keep the string around after setting this
  18. option.
  19. .SH DEFAULT
  20. NULL
  21. .SH PROTOCOLS
  22. This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
  23. This option works only with the following TLS backends:
  24. OpenSSL, Schannel, mbedTLS and wolfSSL
  25. .SH EXAMPLE
  26. .nf
  27. int main(void)
  28. {
  29. CURL *curl = curl_easy_init();
  30. if(curl) {
  31. CURLcode res;
  32. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  33. curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
  34. curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
  35. curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
  36. res = curl_easy_perform(curl);
  37. curl_easy_cleanup(curl);
  38. }
  39. }
  40. .fi
  41. .SH AVAILABILITY
  42. Added in curl 7.9.3
  43. .SH RETURN VALUE
  44. Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or
  45. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  46. .SH SEE ALSO
  47. .BR CURLOPT_SSLCERT (3),
  48. .BR CURLOPT_SSLKEYTYPE (3),
  49. .BR CURLOPT_SSLKEY_BLOB (3)