CURLOPT_CA_CACHE_TIMEOUT.md (2141B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_CA_CACHE_TIMEOUT 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_CAINFO (3) 9 - CURLOPT_CAINFO_BLOB (3) 10 - CURLOPT_CAPATH (3) 11 - CURLOPT_SSL_VERIFYHOST (3) 12 - CURLOPT_SSL_VERIFYPEER (3) 13 Protocol: 14 - TLS 15 TLS-backend: 16 - GnuTLS 17 - OpenSSL 18 - Schannel 19 - wolfSSL 20 Added-in: 7.87.0 21 --- 22 23 # NAME 24 25 CURLOPT_CA_CACHE_TIMEOUT - life-time for cached certificate stores 26 27 # SYNOPSIS 28 29 ~~~c 30 #include <curl/curl.h> 31 32 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CA_CACHE_TIMEOUT, long age); 33 ~~~ 34 35 # DESCRIPTION 36 37 Pass a long, this sets the timeout in seconds. This tells libcurl the maximum 38 time any cached CA certificate store it has in memory may be kept and reused 39 for new connections. Once the timeout has expired, a subsequent fetch 40 requiring a CA certificate has to reload it. 41 42 Building a CA certificate store from a CURLOPT_CAINFO(3) file is a slow 43 operation so curl may cache the generated certificate store internally to 44 speed up future connections. 45 46 Set the timeout to zero to completely disable caching, or set to -1 to retain 47 the cached store remain forever. By default, libcurl caches this info for 24 48 hours. 49 50 # DEFAULT 51 52 86400 (24 hours) 53 54 # %PROTOCOLS% 55 56 # EXAMPLE 57 58 ~~~c 59 int main(void) 60 { 61 CURL *curl = curl_easy_init(); 62 if(curl) { 63 CURLcode res; 64 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 65 66 /* only reuse certificate stores for a short time */ 67 curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 60L); 68 69 res = curl_easy_perform(curl); 70 71 /* in this second request, the cache is not used if more than 72 sixty seconds passed since the previous connection */ 73 res = curl_easy_perform(curl); 74 75 curl_easy_cleanup(curl); 76 } 77 } 78 ~~~ 79 80 # HISTORY 81 82 This option is supported by OpenSSL and its forks (since 7.87.0), Schannel 83 (since 8.5.0), wolfSSL (since 8.9.0) and GnuTLS (since 8.9.0). 84 85 # %AVAILABILITY% 86 87 # RETURN VALUE 88 89 curl_easy_setopt(3) returns a CURLcode indicating success or error. 90 91 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 92 libcurl-errors(3).