xref: /curl/docs/libcurl/opts/CURLOPT_KEYPASSWD.md (revision e3fe0200)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_KEYPASSWD
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_SSH_PRIVATE_KEYFILE (3)
9  - CURLOPT_SSLKEY (3)
10Protocol:
11  - TLS
12TLS-backend:
13  - OpenSSL
14  - mbedTLS
15  - Schannel
16  - wolfSSL
17---
18
19# NAME
20
21CURLOPT_KEYPASSWD - passphrase to private key
22
23# SYNOPSIS
24
25~~~c
26#include <curl/curl.h>
27
28CURLcode curl_easy_setopt(CURL *handle, CURLOPT_KEYPASSWD, char *pwd);
29~~~
30
31# DESCRIPTION
32
33Pass a pointer to a null-terminated string as parameter. It is used as the
34password required to use the CURLOPT_SSLKEY(3) or
35CURLOPT_SSH_PRIVATE_KEYFILE(3) private key. You never need a pass phrase to
36load a certificate but you need one to load your private key.
37
38The application does not have to keep the string around after setting this
39option.
40
41# DEFAULT
42
43NULL
44
45# EXAMPLE
46
47~~~c
48int main(void)
49{
50  CURL *curl = curl_easy_init();
51  if(curl) {
52    CURLcode res;
53    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
54    curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
55    curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
56    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "superman");
57    res = curl_easy_perform(curl);
58    curl_easy_cleanup(curl);
59  }
60}
61~~~
62
63# AVAILABILITY
64
65This option was known as CURLOPT_SSLKEYPASSWD up to 7.16.4 and
66CURLOPT_SSLCERTPASSWD up to 7.9.2.
67
68# RETURN VALUE
69
70Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or
71CURLE_OUT_OF_MEMORY if there was insufficient heap space.
72