1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_CA_CACHE_TIMEOUT
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_CAINFO (3)
9  - CURLOPT_CAINFO_BLOB (3)
10  - CURLOPT_CAPATH (3)
11  - CURLOPT_SSL_VERIFYHOST (3)
12  - CURLOPT_SSL_VERIFYPEER (3)
13Protocol:
14  - TLS
15TLS-backend:
16  - GnuTLS
17  - OpenSSL
18  - Schannel
19  - wolfSSL
20Added-in: 7.87.0
21---
22
23# NAME
24
25CURLOPT_CA_CACHE_TIMEOUT - life-time for cached certificate stores
26
27# SYNOPSIS
28
29~~~c
30#include <curl/curl.h>
31
32CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CA_CACHE_TIMEOUT, long age);
33~~~
34
35# DESCRIPTION
36
37Pass a long, this sets the timeout in seconds. This tells libcurl the maximum
38time any cached CA certificate store it has in memory may be kept and reused
39for new connections. Once the timeout has expired, a subsequent fetch
40requiring a CA certificate has to reload it.
41
42Building a CA certificate store from a CURLOPT_CAINFO(3) file is a slow
43operation so curl may cache the generated certificate store internally to
44speed up future connections.
45
46Set the timeout to zero to completely disable caching, or set to -1 to retain
47the cached store remain forever. By default, libcurl caches this info for 24
48hours.
49
50# DEFAULT
51
5286400 (24 hours)
53
54# %PROTOCOLS%
55
56# EXAMPLE
57
58~~~c
59int 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
82This 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
89Returns CURLE_OK
90