How to clear HTTP / HTTPS Redirect Cache by deleting the cached HSTS Settings in Google Chrome and Mozilla Firefox

How to clear HTTP / HTTPS Redirect Cache by deleting the cached HSTS Settings in Google Chrome and Mozilla Firefox

HTTP Strict Transport Security aka HSTS– is a web security policy mechanism (specified in RFC 6797) which helps to protect websites against protocol downgrade attacks and cookie hijacking; in a nutshell, it allows web servers to declare that web browsers (or other complying user agents) should only interact with them using secure HTTPS connections and never via the insecure HTTP protocol.

Think about it as a HTTP-to-HTTPS permanent redirect, which gets injected in your browser with the following HTTP Header value. Here’s a quick example:

As you can see, the above header would instruct the browser to allow only HTTPSrequests for that domain for the next year (max-age is specified in seconds; 31,536,000 is equal to one non-leap year).

HSTS is an effective countermeasure for man-in-the-middle attacks and is one of the most important HTTP Security Headers that any decent publicly-facing web site should be equipped with: if you want to know more about these headers – and/or require instructions on how to implement them in Nginx, Apache and/or IIS – I strongly suggest toread this post.

The issue

In this article I will talk about a very specific issue that might happen when using HSTS on a HTTPS-enabled website which gets the SSL certificate removed, thus reverting back to HTTP. This can happen for a number of reasons, such as when the website gets transferred to a different host / hostname – together with the SSL certificate or by issuing a new one – while leaving the old instance online… OR, if the System Administrator – you or something else – messes things up during the configuration.

When something like this happens, you might end up with the folllowing error given by your browser(s):

Privacy error: Your connection is not private (NET::ERR_CERT_AUTHORITY_INVALID)

The Fix

Luckily enough, such issue can be easily fixed by clearing the HSTS cache/status for a specific web site. Here’s how to do that in Google Chrome and Mozilla Firefox:

Google Chrome (or Chromium)

  • Close all open/active tabs.
  • Type into the address bar to access the network internals page.
  • Type the domain name into the Query Domain text field and click the corresponding button to check if there are settings present for your domain.
  • If so enter the same domain in the Delete Domain text field and click the button beside it.
  • If you now check again with the Query Domain field you should be getting Not found as answer, meaning that the HSTS settings for that entry have been deleted.

Firefox

  • Close all open/active tabs
  • Open your browser settings and go to History > Show complete history
  • Search for the page you want to delete the HSTS settings for and right-click on it
  • Select Forget About This Siteto get rid of the HSTS cached settings. Notice that doing this will also remove everything saved locally in your browser including cookies, saved passwords etc. for that domain.

 

RELATED POSTS

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies.

View all posts by Ryan