curl/docs/HSTS.md
Daniel Stenberg e5000e797f
GHA: add a job scanning for "bad words" in markdown
This means words, phrases or things we have decided not to use - words that
are spelled right according to the dictionary but we want to avoid. In the
name of consistency and better documentation.

Closes #12764
2024-01-24 08:44:34 +01:00

1.2 KiB

HSTS support

HTTP Strict-Transport-Security. Added as experimental in curl 7.74.0. Supported "for real" since 7.77.0.

Standard

HTTP Strict Transport Security

Behavior

libcurl features an in-memory cache for HSTS hosts, so that subsequent HTTP-only requests to a hostname present in the cache will get internally "redirected" to the HTTPS version.

curl_easy_setopt() options:

  • CURLOPT_HSTS_CTRL - enable HSTS for this easy handle
  • CURLOPT_HSTS - specify filename where to store the HSTS cache on close (and possibly read from at startup)

curl command line options

  • --hsts [filename] - enable HSTS, use the file as HSTS cache. If filename is "" (no length) then no file will be used, only in-memory cache.

HSTS cache file format

Lines starting with # are ignored.

For each hsts entry:

[host name] "YYYYMMDD HH:MM:SS"

The [host name] is dot-prefixed if it includes subdomains.

The time stamp is when the entry expires.

Possible future additions

  • CURLOPT_HSTS_PRELOAD - provide a set of HSTS host names to load first
  • ability to save to something else than a file