• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2c: Copyright (C) Daniel Stenberg, <daniel.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)
11---
12
13# NAME
14
15CURLOPT_SSLCERT_BLOB - SSL client certificate from memory blob
16
17# SYNOPSIS
18
19~~~c
20#include <curl/curl.h>
21
22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERT_BLOB,
23                          struct curl_blob *stblob);
24~~~
25
26# DESCRIPTION
27
28Pass a pointer to a curl_blob structure, which contains (pointer and size) a
29client certificate. The format must be "P12" on Secure Transport or
30Schannel. The format must be "P12" or "PEM" on OpenSSL. The format must be
31"DER" or "PEM" on mbedTLS. The format must be specified with
32CURLOPT_SSLCERTTYPE(3).
33
34If the blob is initialized with the flags member of struct curl_blob set to
35CURL_BLOB_COPY, the application does not have to keep the buffer around after
36setting this.
37
38This option is an alternative to CURLOPT_SSLCERT(3) which instead
39expects a filename as input.
40
41# DEFAULT
42
43NULL
44
45# PROTOCOLS
46
47All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
48
49# EXAMPLE
50
51~~~c
52
53extern char *certificateData; /* point to data */
54extern size_t filesize; /* size of data */
55
56int main(void)
57{
58  CURL *curl = curl_easy_init();
59  if(curl) {
60    CURLcode res;
61    struct curl_blob stblob;
62    stblob.data = certificateData;
63    stblob.len = filesize;
64    stblob.flags = CURL_BLOB_COPY;
65    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
66    curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &stblob);
67    curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "P12");
68    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
69    res = curl_easy_perform(curl);
70    curl_easy_cleanup(curl);
71  }
72}
73~~~
74
75# AVAILABILITY
76
77Added in 7.71.0. This option is supported by the OpenSSL, Secure Transport,
78Schannel and mbedTLS (since 7.78.0) backends.
79
80# RETURN VALUE
81
82Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or
83CURLE_OUT_OF_MEMORY if there was insufficient heap space.
84