1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_HSTS 5Section: 3 6Source: libcurl 7Protocol: 8 - HTTP 9See-also: 10 - CURLOPT_ALTSVC (3) 11 - CURLOPT_HSTS_CTRL (3) 12 - CURLOPT_RESOLVE (3) 13--- 14 15# NAME 16 17CURLOPT_HSTS - HSTS cache filename 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTS, char *filename); 25~~~ 26 27# DESCRIPTION 28 29Make the *filename* point to a filename to load an existing HSTS cache 30from, and to store the cache in when the easy handle is closed. Setting a file 31name with this option also enables HSTS for this handle (the equivalent of 32setting *CURLHSTS_ENABLE* with CURLOPT_HSTS_CTRL(3)). 33 34If the given file does not exist or contains no HSTS entries at startup, the 35HSTS cache simply starts empty. Setting the filename to NULL or "" only 36enables HSTS without reading from or writing to any file. 37 38If this option is set multiple times, libcurl loads cache entries from each 39given file but only stores the last used name for later writing. 40 41# FILE FORMAT 42 43The HSTS cache is saved to and loaded from a text file with one entry per 44physical line. Each line in the file has the following format: 45 46[host] [stamp] 47 48[host] is the domain name for the entry and the name is dot-prefixed if it is 49an entry valid for all subdomains to the name as well or only for the exact 50name. 51 52[stamp] is the time (in UTC) when the entry expires and it uses the format 53"YYYYMMDD HH:MM:SS". 54 55Lines starting with "#" are treated as comments and are ignored. There is 56currently no length or size limit. 57 58# DEFAULT 59 60NULL, no filename 61 62# EXAMPLE 63 64~~~c 65int main(void) 66{ 67 CURL *curl = curl_easy_init(); 68 if(curl) { 69 curl_easy_setopt(curl, CURLOPT_HSTS, "/home/user/.hsts-cache"); 70 curl_easy_perform(curl); 71 } 72} 73~~~ 74 75# AVAILABILITY 76 77Added in 7.74.0 78 79# RETURN VALUE 80 81Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 82