1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_SSLKEY_BLOB 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_SSLKEY (3) 9 - CURLOPT_SSLKEYTYPE (3) 10Protocol: 11 - TLS 12TLS-backend: 13 - OpenSSL 14--- 15 16# NAME 17 18CURLOPT_SSLKEY_BLOB - private key for client cert from memory blob 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY_BLOB, 26 struct curl_blob *blob); 27~~~ 28 29# DESCRIPTION 30 31Pass a pointer to a curl_blob structure, which contains information (pointer 32and size) for a private key. Compatible with OpenSSL. The format (like "PEM") 33must be specified with CURLOPT_SSLKEYTYPE(3). 34 35If the blob is initialized with the flags member of struct curl_blob set to 36CURL_BLOB_COPY, the application does not have to keep the buffer around after 37setting this. 38 39This option is an alternative to CURLOPT_SSLKEY(3) which instead expects a 40filename as input. 41 42# DEFAULT 43 44NULL 45 46# EXAMPLE 47 48~~~c 49 50extern char *certificateData; /* point to cert */ 51extern size_t filesize; /* size of cert */ 52 53extern char *privateKeyData; /* point to key */ 54extern size_t privateKeySize; /* size of key */ 55 56int main(void) 57{ 58 CURL *curl = curl_easy_init(); 59 if(curl) { 60 CURLcode res; 61 struct curl_blob blob; 62 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); 63 blob.data = certificateData; 64 blob.len = filesize; 65 blob.flags = CURL_BLOB_COPY; 66 curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &blob); 67 curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); 68 69 blob.data = privateKeyData; 70 blob.len = privateKeySize; 71 curl_easy_setopt(curl, CURLOPT_SSLKEY_BLOB, &blob); 72 curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); 73 curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM"); 74 res = curl_easy_perform(curl); 75 curl_easy_cleanup(curl); 76 } 77} 78~~~ 79 80# AVAILABILITY 81 82Added in 7.71.0. This option is supported by the OpenSSL backends. 83 84# RETURN VALUE 85 86Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or 87CURLE_OUT_OF_MEMORY if there was insufficient heap space. 88