xref: /curl/docs/libcurl/opts/CURLOPT_SSLKEY.md (revision e3fe0200)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_SSLKEY
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_SSLCERT (3)
9  - CURLOPT_SSLKEYTYPE (3)
10  - CURLOPT_SSLKEY_BLOB (3)
11Protocol:
12  - TLS
13TLS-backend:
14  - OpenSSL
15  - mbedTLS
16  - Schannel
17  - wolfSSL
18---
19
20# NAME
21
22CURLOPT_SSLKEY - private key file for TLS and SSL client cert
23
24# SYNOPSIS
25
26~~~c
27#include <curl/curl.h>
28
29CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY, char *keyfile);
30~~~
31
32# DESCRIPTION
33
34Pass a pointer to a null-terminated string as parameter. The string should be
35the filename of your private key. The default format is "PEM" and can be
36changed with CURLOPT_SSLKEYTYPE(3).
37
38(Windows, iOS and Mac OS X) This option is ignored by Secure Transport and
39Schannel SSL backends because they expect the private key to be already present
40in the key-chain or PKCS#12 file containing the certificate.
41
42The application does not have to keep the string around after setting this
43option.
44
45# DEFAULT
46
47NULL
48
49# EXAMPLE
50
51~~~c
52int main(void)
53{
54  CURL *curl = curl_easy_init();
55  if(curl) {
56    CURLcode res;
57    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
58    curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
59    curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
60    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
61    res = curl_easy_perform(curl);
62    curl_easy_cleanup(curl);
63  }
64}
65~~~
66
67# AVAILABILITY
68
69If built TLS enabled.
70
71# RETURN VALUE
72
73Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or
74CURLE_OUT_OF_MEMORY if there was insufficient heap space.
75