CURLOPT_CAINFO.md (2218B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_CAINFO 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLINFO_CAINFO (3) 9 - CURLOPT_CAINFO_BLOB (3) 10 - CURLOPT_CAPATH (3) 11 - CURLOPT_CA_CACHE_TIMEOUT (3) 12 - CURLOPT_SSL_VERIFYHOST (3) 13 - CURLOPT_SSL_VERIFYPEER (3) 14 Protocol: 15 - TLS 16 TLS-backend: 17 - All 18 Added-in: 7.4.2 19 --- 20 21 # NAME 22 23 CURLOPT_CAINFO - path to Certificate Authority (CA) bundle 24 25 # SYNOPSIS 26 27 ~~~c 28 #include <curl/curl.h> 29 30 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO, char *path); 31 ~~~ 32 33 # DESCRIPTION 34 35 Pass a char pointer to a null-terminated string naming a file holding one or 36 more certificates to verify the peer with. 37 38 If CURLOPT_SSL_VERIFYPEER(3) is zero and you avoid verifying the 39 server's certificate, CURLOPT_CAINFO(3) need not even indicate an 40 accessible file. 41 42 This option is by default set to the system path where libcurl's CA 43 certificate bundle is assumed to be stored, as established at build time. 44 45 (Schannel) This option is supported for Schannel in Windows 7 or later but we 46 recommend not using it until Windows 8 since it works better starting then. 47 If the option is not set, then curl uses the certificates in the Windows' 48 store of root certificates (the default for Schannel). 49 50 The application does not have to keep the string around after setting this 51 option. 52 53 Using this option multiple times makes the last set string override the 54 previous ones. Set it to NULL to disable its use again. 55 56 The default value for this can be figured out with CURLINFO_CAINFO(3). 57 58 # DEFAULT 59 60 Built-in system specific. When curl is built with Schannel, this option is not 61 set by default. 62 63 # %PROTOCOLS% 64 65 # EXAMPLE 66 67 ~~~c 68 int main(void) 69 { 70 CURL *curl = curl_easy_init(); 71 if(curl) { 72 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); 73 curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/certs/cabundle.pem"); 74 curl_easy_perform(curl); 75 curl_easy_cleanup(curl); 76 } 77 } 78 ~~~ 79 80 # HISTORY 81 82 Schannel support added in libcurl 7.60. 83 84 # %AVAILABILITY% 85 86 # RETURN VALUE 87 88 curl_easy_setopt(3) returns a CURLcode indicating success or error. 89 90 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 91 libcurl-errors(3).