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