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