xref: /aosp_15_r20/external/curl/docs/libcurl/opts/CURLOPT_CAPATH.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_CAPATH
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerSee-also:
8*6236dae4SAndroid Build Coastguard Worker  - CURLINFO_CAPATH (3)
9*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_CAINFO (3)
10*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_DEBUGFUNCTION (3)
11*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_STDERR (3)
12*6236dae4SAndroid Build Coastguard WorkerProtocol:
13*6236dae4SAndroid Build Coastguard Worker  - TLS
14*6236dae4SAndroid Build Coastguard WorkerTLS-backend:
15*6236dae4SAndroid Build Coastguard Worker  - OpenSSL
16*6236dae4SAndroid Build Coastguard Worker  - GnuTLS
17*6236dae4SAndroid Build Coastguard Worker  - mbedTLS
18*6236dae4SAndroid Build Coastguard Worker  - wolfSSL
19*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.9.8
20*6236dae4SAndroid Build Coastguard Worker---
21*6236dae4SAndroid Build Coastguard Worker
22*6236dae4SAndroid Build Coastguard Worker# NAME
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard WorkerCURLOPT_CAPATH - directory holding CA certificates
25*6236dae4SAndroid Build Coastguard Worker
26*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS
27*6236dae4SAndroid Build Coastguard Worker
28*6236dae4SAndroid Build Coastguard Worker~~~c
29*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h>
30*6236dae4SAndroid Build Coastguard Worker
31*6236dae4SAndroid Build Coastguard WorkerCURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAPATH, char *capath);
32*6236dae4SAndroid Build Coastguard Worker~~~
33*6236dae4SAndroid Build Coastguard Worker
34*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION
35*6236dae4SAndroid Build Coastguard Worker
36*6236dae4SAndroid Build Coastguard WorkerPass a char pointer to a null-terminated string naming a directory holding
37*6236dae4SAndroid Build Coastguard Workermultiple CA certificates to verify the peer with. If libcurl is built against
38*6236dae4SAndroid Build Coastguard WorkerOpenSSL, the certificate directory must be prepared using the OpenSSL c_rehash
39*6236dae4SAndroid Build Coastguard Workerutility. This makes sense only when used in combination with the
40*6236dae4SAndroid Build Coastguard WorkerCURLOPT_SSL_VERIFYPEER(3) option.
41*6236dae4SAndroid Build Coastguard Worker
42*6236dae4SAndroid Build Coastguard WorkerThe CURLOPT_CAPATH(3) function apparently does not work in Windows due
43*6236dae4SAndroid Build Coastguard Workerto some limitation in OpenSSL.
44*6236dae4SAndroid Build Coastguard Worker
45*6236dae4SAndroid Build Coastguard WorkerThe application does not have to keep the string around after setting this
46*6236dae4SAndroid Build Coastguard Workeroption.
47*6236dae4SAndroid Build Coastguard Worker
48*6236dae4SAndroid Build Coastguard WorkerUsing this option multiple times makes the last set string override the
49*6236dae4SAndroid Build Coastguard Workerprevious ones. Set it to NULL to disable its use again.
50*6236dae4SAndroid Build Coastguard Worker
51*6236dae4SAndroid Build Coastguard WorkerThe default value for this can be figured out with CURLINFO_CAPATH(3).
52*6236dae4SAndroid Build Coastguard Worker
53*6236dae4SAndroid Build Coastguard Worker# DEFAULT
54*6236dae4SAndroid Build Coastguard Worker
55*6236dae4SAndroid Build Coastguard WorkerA path detected at build time.
56*6236dae4SAndroid Build Coastguard Worker
57*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS%
58*6236dae4SAndroid Build Coastguard Worker
59*6236dae4SAndroid Build Coastguard Worker# EXAMPLE
60*6236dae4SAndroid Build Coastguard Worker
61*6236dae4SAndroid Build Coastguard Worker~~~c
62*6236dae4SAndroid Build Coastguard Workerint main(void)
63*6236dae4SAndroid Build Coastguard Worker{
64*6236dae4SAndroid Build Coastguard Worker  CURL *curl = curl_easy_init();
65*6236dae4SAndroid Build Coastguard Worker  if(curl) {
66*6236dae4SAndroid Build Coastguard Worker    CURLcode res;
67*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
68*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_CAPATH, "/etc/cert-dir");
69*6236dae4SAndroid Build Coastguard Worker    res = curl_easy_perform(curl);
70*6236dae4SAndroid Build Coastguard Worker    curl_easy_cleanup(curl);
71*6236dae4SAndroid Build Coastguard Worker  }
72*6236dae4SAndroid Build Coastguard Worker}
73*6236dae4SAndroid Build Coastguard Worker~~~
74*6236dae4SAndroid Build Coastguard Worker
75*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY%
76*6236dae4SAndroid Build Coastguard Worker
77*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE
78*6236dae4SAndroid Build Coastguard Worker
79*6236dae4SAndroid Build Coastguard WorkerCURLE_OK if supported; or an error such as:
80*6236dae4SAndroid Build Coastguard Worker
81*6236dae4SAndroid Build Coastguard WorkerCURLE_NOT_BUILT_IN - Not supported by the SSL backend
82*6236dae4SAndroid Build Coastguard Worker
83*6236dae4SAndroid Build Coastguard WorkerCURLE_UNKNOWN_OPTION
84*6236dae4SAndroid Build Coastguard Worker
85*6236dae4SAndroid Build Coastguard WorkerCURLE_OUT_OF_MEMORY
86