xref: /aosp_15_r20/external/curl/docs/libcurl/opts/CURLOPT_SSLCERT.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerTitle: CURLOPT_SSLCERT
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerSee-also:
8*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_KEYPASSWD (3)
9*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_SSLCERTTYPE (3)
10*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_SSLKEY (3)
11*6236dae4SAndroid Build Coastguard WorkerProtocol:
12*6236dae4SAndroid Build Coastguard Worker  - TLS
13*6236dae4SAndroid Build Coastguard WorkerTLS-backend:
14*6236dae4SAndroid Build Coastguard Worker  - OpenSSL
15*6236dae4SAndroid Build Coastguard Worker  - GnuTLS
16*6236dae4SAndroid Build Coastguard Worker  - mbedTLS
17*6236dae4SAndroid Build Coastguard Worker  - Schannel
18*6236dae4SAndroid Build Coastguard Worker  - Secure Transport
19*6236dae4SAndroid Build Coastguard Worker  - wolfSSL
20*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.1
21*6236dae4SAndroid Build Coastguard Worker---
22*6236dae4SAndroid Build Coastguard Worker
23*6236dae4SAndroid Build Coastguard Worker# NAME
24*6236dae4SAndroid Build Coastguard Worker
25*6236dae4SAndroid Build Coastguard WorkerCURLOPT_SSLCERT - SSL client certificate
26*6236dae4SAndroid Build Coastguard Worker
27*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS
28*6236dae4SAndroid Build Coastguard Worker
29*6236dae4SAndroid Build Coastguard Worker~~~c
30*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h>
31*6236dae4SAndroid Build Coastguard Worker
32*6236dae4SAndroid Build Coastguard WorkerCURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERT, char *cert);
33*6236dae4SAndroid Build Coastguard Worker~~~
34*6236dae4SAndroid Build Coastguard Worker
35*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION
36*6236dae4SAndroid Build Coastguard Worker
37*6236dae4SAndroid Build Coastguard WorkerPass a pointer to a null-terminated string as parameter. The string should be
38*6236dae4SAndroid Build Coastguard Workerthe filename of your client certificate. The default format is `P12` on Secure
39*6236dae4SAndroid Build Coastguard WorkerTransport and `PEM` on other engines, and can be changed with
40*6236dae4SAndroid Build Coastguard WorkerCURLOPT_SSLCERTTYPE(3).
41*6236dae4SAndroid Build Coastguard Worker
42*6236dae4SAndroid Build Coastguard WorkerWith Secure Transport, this can also be the nickname of the certificate you
43*6236dae4SAndroid Build Coastguard Workerwish to authenticate with as it is named in the security database. If you want
44*6236dae4SAndroid Build Coastguard Workerto use a file from the current directory, please precede it with `./` prefix,
45*6236dae4SAndroid Build Coastguard Workerin order to avoid confusion with a nickname.
46*6236dae4SAndroid Build Coastguard Worker
47*6236dae4SAndroid Build Coastguard Worker(Schannel only) Client certificates can be specified by a path expression to a
48*6236dae4SAndroid Build Coastguard Workercertificate store. (You can import *PFX* to a store first). You can use
49*6236dae4SAndroid Build Coastguard Worker"\<store location\>\\\<store name\>\\\<thumbprint\>" to refer to a certificate
50*6236dae4SAndroid Build Coastguard Workerin the system certificates store, for example,
51*6236dae4SAndroid Build Coastguard Worker**"CurrentUser\\MY\\934a7ac6f8a5d5"**. The thumbprint is usually a SHA-1 hex
52*6236dae4SAndroid Build Coastguard Workerstring which you can see in certificate details. Following store locations are
53*6236dae4SAndroid Build Coastguard Workersupported: **CurrentUser**, **LocalMachine**, **CurrentService**,
54*6236dae4SAndroid Build Coastguard Worker**Services**, **CurrentUserGroupPolicy**, **LocalMachineGroupPolicy**,
55*6236dae4SAndroid Build Coastguard Worker**LocalMachineEnterprise**. Schannel also support P12 certificate file, with
56*6236dae4SAndroid Build Coastguard Workerthe string `P12` specified with CURLOPT_SSLCERTTYPE(3).
57*6236dae4SAndroid Build Coastguard Worker
58*6236dae4SAndroid Build Coastguard WorkerWhen using a client certificate, you most likely also need to provide a
59*6236dae4SAndroid Build Coastguard Workerprivate key with CURLOPT_SSLKEY(3).
60*6236dae4SAndroid Build Coastguard Worker
61*6236dae4SAndroid Build Coastguard WorkerThe application does not have to keep the string around after setting this
62*6236dae4SAndroid Build Coastguard Workeroption.
63*6236dae4SAndroid Build Coastguard Worker
64*6236dae4SAndroid Build Coastguard WorkerUsing this option multiple times makes the last set string override the
65*6236dae4SAndroid Build Coastguard Workerprevious ones. Set it to NULL to disable its use again.
66*6236dae4SAndroid Build Coastguard Worker
67*6236dae4SAndroid Build Coastguard Worker# DEFAULT
68*6236dae4SAndroid Build Coastguard Worker
69*6236dae4SAndroid Build Coastguard WorkerNULL
70*6236dae4SAndroid Build Coastguard Worker
71*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS%
72*6236dae4SAndroid Build Coastguard Worker
73*6236dae4SAndroid Build Coastguard Worker# EXAMPLE
74*6236dae4SAndroid Build Coastguard Worker
75*6236dae4SAndroid Build Coastguard Worker~~~c
76*6236dae4SAndroid Build Coastguard Workerint main(void)
77*6236dae4SAndroid Build Coastguard Worker{
78*6236dae4SAndroid Build Coastguard Worker  CURL *curl = curl_easy_init();
79*6236dae4SAndroid Build Coastguard Worker  if(curl) {
80*6236dae4SAndroid Build Coastguard Worker    CURLcode res;
81*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
82*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
83*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
84*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
85*6236dae4SAndroid Build Coastguard Worker    res = curl_easy_perform(curl);
86*6236dae4SAndroid Build Coastguard Worker    curl_easy_cleanup(curl);
87*6236dae4SAndroid Build Coastguard Worker  }
88*6236dae4SAndroid Build Coastguard Worker}
89*6236dae4SAndroid Build Coastguard Worker~~~
90*6236dae4SAndroid Build Coastguard Worker
91*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY%
92*6236dae4SAndroid Build Coastguard Worker
93*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE
94*6236dae4SAndroid Build Coastguard Worker
95*6236dae4SAndroid Build Coastguard WorkerReturns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or
96*6236dae4SAndroid Build Coastguard WorkerCURLE_OUT_OF_MEMORY if there was insufficient heap space.
97