CURLOPT_SSLKEY.md (1755B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_SSLKEY 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_SSLCERT (3) 9 - CURLOPT_SSLKEYTYPE (3) 10 - CURLOPT_SSLKEY_BLOB (3) 11 Protocol: 12 - TLS 13 TLS-backend: 14 - OpenSSL 15 - mbedTLS 16 - Schannel 17 - wolfSSL 18 Added-in: 7.9.3 19 --- 20 21 # NAME 22 23 CURLOPT_SSLKEY - private key file for TLS and SSL client cert 24 25 # SYNOPSIS 26 27 ~~~c 28 #include <curl/curl.h> 29 30 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY, char *keyfile); 31 ~~~ 32 33 # DESCRIPTION 34 35 Pass a pointer to a null-terminated string as parameter. The string should be 36 the filename of your private key. The default format is "PEM" and can be 37 changed with CURLOPT_SSLKEYTYPE(3). 38 39 (Windows) This option is ignored by the Schannel SSL backend because it 40 expects the private key to be already present in the key-chain or PKCS#12 file 41 containing the certificate. 42 43 The application does not have to keep the string around after setting this 44 option. 45 46 Using this option multiple times makes the last set string override the 47 previous ones. Set it to NULL to disable its use again. 48 49 # DEFAULT 50 51 NULL 52 53 # %PROTOCOLS% 54 55 # EXAMPLE 56 57 ~~~c 58 int main(void) 59 { 60 CURL *curl = curl_easy_init(); 61 if(curl) { 62 CURLcode res; 63 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); 64 curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem"); 65 curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); 66 curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); 67 res = curl_easy_perform(curl); 68 curl_easy_cleanup(curl); 69 } 70 } 71 ~~~ 72 73 # %AVAILABILITY% 74 75 # RETURN VALUE 76 77 curl_easy_setopt(3) returns a CURLcode indicating success or error. 78 79 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 80 libcurl-errors(3).