How to Fix “Your Connection Is Not Secure” in Firefox and Selenium

We use Selenium and Firefox to verify our BDD specifications. That combination worked well until the last update to Firefox 75. Instead of our application on the developer machine, Firefox only showed us the “Your connection is not secure error” overlay. We depend on fast feedback cycles and needed a solution quickly.

I found some interesting looking ideas with your own Certificate Authority (CA) that creates a certificate for localhost instead of the self-signed certificate from IIS Express. IIS Express is a pain to change certificates and the only thing I could show after hours of trial and error was the new error SEC_ERROR_UNKNOWN_ISSUER. However, this error message led to a configuration option for the Firefox driver that solved our problem.

The FirefoxDriver accepts a FirefoxOptions object, in which we can tell Firefox to accept insecure certificates:

In the end, we only needed two additional lines of setup code to get our scenarios running again. No local CA, no special configuration for IIS Express. If you run into the same problem, add a FirefoxOptions object and set it accordingly.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.