CURLOPT_SSLCERT.3 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. .\" generated by cd2nroff 0.1 from CURLOPT_SSLCERT.md
  2. .TH CURLOPT_SSLCERT 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_SSLCERT \- SSL client certificate
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERT, char *cert);
  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 client certificate. The default format is \fIP12\fP on Secure
  13. Transport and \fIPEM\fP on other engines, and can be changed with
  14. \fICURLOPT_SSLCERTTYPE(3)\fP.
  15. With Secure Transport, this can also be the nickname of the certificate you
  16. wish to authenticate with as it is named in the security database. If you want
  17. to use a file from the current directory, please precede it with \fI./\fP prefix,
  18. in order to avoid confusion with a nickname.
  19. (Schannel only) Client certificates can be specified by a path expression to a
  20. certificate store. (You can import \fIPFX\fP to a store first). You can use
  21. \&"<store location>\\<store name>\\<thumbprint>" to refer to a certificate
  22. in the system certificates store, for example,
  23. \fB"CurrentUser\\MY\\934a7ac6f8a5d579285a74fa"\fP. The thumbprint is usually a
  24. SHA\-1 hex string which you can see in certificate details. Following store
  25. locations are supported: \fBCurrentUser\fP, \fBLocalMachine\fP,
  26. \fBCurrentService\fP, \fBServices\fP, \fBCurrentUserGroupPolicy\fP,
  27. \fBLocalMachineGroupPolicy\fP, \fBLocalMachineEnterprise\fP. Schannel also support
  28. P12 certificate file, with the string \fIP12\fP specified with
  29. \fICURLOPT_SSLCERTTYPE(3)\fP.
  30. When using a client certificate, you most likely also need to provide a
  31. private key with \fICURLOPT_SSLKEY(3)\fP.
  32. The application does not have to keep the string around after setting this
  33. option.
  34. .SH DEFAULT
  35. NULL
  36. .SH PROTOCOLS
  37. This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
  38. This option works only with the following TLS backends:
  39. GnuTLS, OpenSSL, Schannel, Secure Transport, mbedTLS and wolfSSL
  40. .SH EXAMPLE
  41. .nf
  42. int main(void)
  43. {
  44. CURL *curl = curl_easy_init();
  45. if(curl) {
  46. CURLcode res;
  47. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  48. curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
  49. curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
  50. curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
  51. res = curl_easy_perform(curl);
  52. curl_easy_cleanup(curl);
  53. }
  54. }
  55. .fi
  56. .SH AVAILABILITY
  57. Added in curl 7.1
  58. .SH RETURN VALUE
  59. Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or
  60. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  61. .SH SEE ALSO
  62. .BR CURLOPT_KEYPASSWD (3),
  63. .BR CURLOPT_SSLCERTTYPE (3),
  64. .BR CURLOPT_SSLKEY (3)