1CURLOPT_CAINFO(3) curl_easy_setopt options CURLOPT_CAINFO(3)
2
3
4
6 CURLOPT_CAINFO - path to Certificate Authority (CA) bundle
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO, char *path);
12
14 Pass a char * to a null-terminated string naming a file holding one or
15 more certificates to verify the peer with.
16
17 If CURLOPT_SSL_VERIFYPEER(3) is zero and you avoid verifying the
18 server's certificate, CURLOPT_CAINFO(3) need not even indicate an ac‐
19 cessible file.
20
21 This option is by default set to the system path where libcurl's cacert
22 bundle is assumed to be stored, as established at build time.
23
24 If curl is built against the NSS SSL library, the NSS PEM PKCS#11 mod‐
25 ule (libnsspem.so) needs to be available for this option to work prop‐
26 erly. Starting with curl-7.55.0, if both CURLOPT_CAINFO(3) and CUR‐
27 LOPT_CAPATH(3) are unset, NSS-linked libcurl tries to load libnss‐
28 ckbi.so, which contains a more comprehensive set of trust information
29 than supported by nss-pem, because libnssckbi.so also includes informa‐
30 tion about distrusted certificates.
31
32 (iOS and macOS) When curl uses Secure Transport this option is sup‐
33 ported. If the option is not set, then curl will use the certificates
34 in the system and user Keychain to verify the peer.
35
36 (Schannel) This option is supported for Schannel in Windows 7 or later
37 but we recommend not using it until Windows 8 since it works better
38 starting then. If the option is not set, then curl will use the cer‐
39 tificates in the Windows' store of root certificates (the default for
40 Schannel).
41
42 The application does not have to keep the string around after setting
43 this option.
44
45 The default value for this can be figured out with CURLINFO_CAINFO(3).
46
48 Built-in system specific. When curl is built with Secure Transport or
49 Schannel, this option is not set by default.
50
52 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
53
55 CURL *curl = curl_easy_init();
56 if(curl) {
57 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
58 curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/certs/cabundle.pem");
59 ret = curl_easy_perform(curl);
60 curl_easy_cleanup(curl);
61 }
62
64 For the SSL engines that do not support certificate files the CUR‐
65 LOPT_CAINFO option is ignored. Schannel support added in libcurl 7.60.
66
68 Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if
69 not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space.
70
72 CURLOPT_CAINFO_BLOB(3), CURLOPT_CAPATH(3), CURLOPT_SSL_VERIFYPEER(3),
73 CURLOPT_SSL_VERIFYHOST(3), CURLINFO_CAINFO(3),
74
75
76
77libcurl 7.85.0 May 17, 2022 CURLOPT_CAINFO(3)