xref: /aosp_15_r20/external/curl/docs/libcurl/opts/CURLOPT_CAINFO.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_CAINFO
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerSee-also:
8*6236dae4SAndroid Build Coastguard Worker  - CURLINFO_CAINFO (3)
9*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_CAINFO_BLOB (3)
10*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_CAPATH (3)
11*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_CA_CACHE_TIMEOUT (3)
12*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_SSL_VERIFYHOST (3)
13*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_SSL_VERIFYPEER (3)
14*6236dae4SAndroid Build Coastguard WorkerProtocol:
15*6236dae4SAndroid Build Coastguard Worker  - TLS
16*6236dae4SAndroid Build Coastguard WorkerTLS-backend:
17*6236dae4SAndroid Build Coastguard Worker  - All
18*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.4.2
19*6236dae4SAndroid Build Coastguard Worker---
20*6236dae4SAndroid Build Coastguard Worker
21*6236dae4SAndroid Build Coastguard Worker# NAME
22*6236dae4SAndroid Build Coastguard Worker
23*6236dae4SAndroid Build Coastguard WorkerCURLOPT_CAINFO - path to Certificate Authority (CA) bundle
24*6236dae4SAndroid Build Coastguard Worker
25*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS
26*6236dae4SAndroid Build Coastguard Worker
27*6236dae4SAndroid Build Coastguard Worker~~~c
28*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h>
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard WorkerCURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO, char *path);
31*6236dae4SAndroid Build Coastguard Worker~~~
32*6236dae4SAndroid Build Coastguard Worker
33*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION
34*6236dae4SAndroid Build Coastguard Worker
35*6236dae4SAndroid Build Coastguard WorkerPass a char pointer to a null-terminated string naming a file holding one or
36*6236dae4SAndroid Build Coastguard Workermore certificates to verify the peer with.
37*6236dae4SAndroid Build Coastguard Worker
38*6236dae4SAndroid Build Coastguard WorkerIf CURLOPT_SSL_VERIFYPEER(3) is zero and you avoid verifying the
39*6236dae4SAndroid Build Coastguard Workerserver's certificate, CURLOPT_CAINFO(3) need not even indicate an
40*6236dae4SAndroid Build Coastguard Workeraccessible file.
41*6236dae4SAndroid Build Coastguard Worker
42*6236dae4SAndroid Build Coastguard WorkerThis option is by default set to the system path where libcurl's CA
43*6236dae4SAndroid Build Coastguard Workercertificate bundle is assumed to be stored, as established at build time.
44*6236dae4SAndroid Build Coastguard Worker
45*6236dae4SAndroid Build Coastguard Worker(iOS and macOS) When curl uses Secure Transport this option is supported. If
46*6236dae4SAndroid Build Coastguard Workerthe option is not set, then curl uses the certificates in the system and user
47*6236dae4SAndroid Build Coastguard WorkerKeychain to verify the peer.
48*6236dae4SAndroid Build Coastguard Worker
49*6236dae4SAndroid Build Coastguard Worker(Schannel) This option is supported for Schannel in Windows 7 or later but we
50*6236dae4SAndroid Build Coastguard Workerrecommend not using it until Windows 8 since it works better starting then.
51*6236dae4SAndroid Build Coastguard WorkerIf the option is not set, then curl uses the certificates in the Windows'
52*6236dae4SAndroid Build Coastguard Workerstore of root certificates (the default for Schannel).
53*6236dae4SAndroid Build Coastguard Worker
54*6236dae4SAndroid Build Coastguard WorkerThe application does not have to keep the string around after setting this
55*6236dae4SAndroid Build Coastguard Workeroption.
56*6236dae4SAndroid Build Coastguard Worker
57*6236dae4SAndroid Build Coastguard WorkerUsing this option multiple times makes the last set string override the
58*6236dae4SAndroid Build Coastguard Workerprevious ones. Set it to NULL to disable its use again.
59*6236dae4SAndroid Build Coastguard Worker
60*6236dae4SAndroid Build Coastguard WorkerThe default value for this can be figured out with CURLINFO_CAINFO(3).
61*6236dae4SAndroid Build Coastguard Worker
62*6236dae4SAndroid Build Coastguard Worker# DEFAULT
63*6236dae4SAndroid Build Coastguard Worker
64*6236dae4SAndroid Build Coastguard WorkerBuilt-in system specific. When curl is built with Secure Transport or
65*6236dae4SAndroid Build Coastguard WorkerSchannel, this option is not set by default.
66*6236dae4SAndroid Build Coastguard Worker
67*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS%
68*6236dae4SAndroid Build Coastguard Worker
69*6236dae4SAndroid Build Coastguard Worker# EXAMPLE
70*6236dae4SAndroid Build Coastguard Worker
71*6236dae4SAndroid Build Coastguard Worker~~~c
72*6236dae4SAndroid Build Coastguard Workerint main(void)
73*6236dae4SAndroid Build Coastguard Worker{
74*6236dae4SAndroid Build Coastguard Worker  CURL *curl = curl_easy_init();
75*6236dae4SAndroid Build Coastguard Worker  if(curl) {
76*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
77*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/certs/cabundle.pem");
78*6236dae4SAndroid Build Coastguard Worker    curl_easy_perform(curl);
79*6236dae4SAndroid Build Coastguard Worker    curl_easy_cleanup(curl);
80*6236dae4SAndroid Build Coastguard Worker  }
81*6236dae4SAndroid Build Coastguard Worker}
82*6236dae4SAndroid Build Coastguard Worker~~~
83*6236dae4SAndroid Build Coastguard Worker
84*6236dae4SAndroid Build Coastguard Worker# HISTORY
85*6236dae4SAndroid Build Coastguard Worker
86*6236dae4SAndroid Build Coastguard WorkerSchannel support added in libcurl 7.60.
87*6236dae4SAndroid Build Coastguard Worker
88*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY%
89*6236dae4SAndroid Build Coastguard Worker
90*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE
91*6236dae4SAndroid Build Coastguard Worker
92*6236dae4SAndroid Build Coastguard WorkerReturns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
93*6236dae4SAndroid Build Coastguard WorkerCURLE_OUT_OF_MEMORY if there was insufficient heap space.
94