- HSTS (HTTP Strict Transport Security) prevents your browser from visiting a website over an unencrypted “http://…” url. Instead you have to use the encrypted “https://…” url, otherwise your browser refuses to load the website.
Either the webserver of the website you are visiting suggests the use of HSTS to your browser by sending an additional HTTP header, or you manually configure a certain website yourself in your browser. - Apache requires the module mod_headers to make the necessary changes to the HTTP headers.
- Add this to your Apache vhost configuration:
Header always set Strict-Transport-Security “max-age=15768000; includeSubDomains; preload”
For a description of all options see RFC: https://tools.ietf.org/html/rfc6797#section-6
The “preload” option is not part of the RFC. It just signals that you want your site to be added to the browser builtin list of HSTS sites (see below). If you do not plan to get listed, you may omit this option. - Visit the site at least once using HTTPS in your Chrome browser (“trust on first use”). The HSTS configuration of the site (provided by the Apache STS header) will be added to an internal Chrome list. HSTS really depends on this internal browser list. Webservers only send an additional HTTP header that webbrowsers may or may not honor.
- Add, delete or check websites in your Chrome browser:
chrome://net-internals/#hsts
Changes take place immediately without having to restart Chrome.
You can add sites even if they don’t send the special STS header.
You can combine those entries with PKP (Public Key Pinning) by providing fingerprints for all accepted public keys of a website. - Chrome ships with a builtin list of sites that require HSTS. If you run a large public website, you might want to get included in that list: https://hstspreload.appspot.com/
These builtin sites get listed as “static_…” in your internal Chrome browser list. All other sites (added manually or by honoring the STS header) get listed as “dynamic_…”. - You cannot delete site entries from the builtin list (assuming that you use the official Chrome browser and that it has not been manipulated).
- This is the message you get in Chrome when HSTS is violated on a website (in this case the certificate of http://www.rolandschnabel.de has expired and therefore Chrome refuses to establish the HTTPS connection):
You cannot visit www.rolandschnabel.de right now because the website uses HSTS. Network errors and attacks are usually temporary, so this page will probably work later.
Important things to note:
- Even for HSTS enabled sites, you may still be able to type in the “http://…” URL in the browser address bar. Chrome automatically recognizes the URL and redirects you to the corresponding “https://…” URL.
This is different from traditional HTTP redirects, because no unencrypted traffic is sent over the network. The redirection already takes place in the browser.
The downside of this behaviour is that it makes it hard for people to identify if a website is using HSTS or simply redirects all traffic from HTTP/port 80 to HTTPS/port 443 (HTTP status codes 3xx). - Many browser plugins now offer the same functionality (redirect some or all website addresses to HTTPS URLs).
- Maybe some day HTTPS URLs become the default in webbrowsers. If you type a URL in the address bar, or select a URL without the leading “http(s)://”, the browser first redirects you automatically to the HTTPS URL. Only if there is no connection possible, you will receive a warning message and get redirected to the HTTP URL. Let’s make HTTPS the default in browsers and accept HTTP only for a small number of exceptions.
No green lock icon for SSL encrypted websites, just red unlock icons for unencrypted websites.