DEV Community

Ola Johansson
Ola Johansson

Posted on

1

Make your self-signed certificate trusted by Chrome (and Firefox)

These instructions are for Windows and works for me™ in Chrome.

Create a self-signed certificate with a DnsName

Create a new certificate with powershell

New-SelfSignedCertificate -DnsName localhost -CertStoreLocation cert:\LocalMachine\My

The DnsName is important and if you use a custom domain via a host file you should add the domain you use there.

Make sure you use this certificate on your localhost

Picture of setting your certificate for your host in IIS

Export the certificate from Chrome

  1. Go to your localhost website and open up the inspector
  2. Under the security tab, click the "View Certificate" button.
  3. Go to the details tab in the dialog and click "Copy to file"
  4. Follow the wizard and choose the Cryptographic Message Syntax Standard - PKCS #7 (i do not think the "Include all checkbox" is important)
  5. Save it somewhere.

Import the certificate to the "Trusted Root Certification Authorites"

  1. Go to Chrome Settings
  2. Click advanced at the bottom
  3. Click the Manage Certificates link to open the certificate dialog
  4. Click import
  5. Follow the wizard and pick your exorted certificate file
  6. Click browse and choose "Trusted Root Certification Authorites"
  7. Done!

After this you should restart Chrome and you should not get any warnings.

All this information was collected at various places in this Stack Overflow question: https://stackoverflow.com/questions/7580508/getting-chrome-to-accept-self-signed-localhost-certificate

Bonus - Make it work in Firefox as well

Apparently Firefox doesn't use the global windows store for certificates. But it's easy to fix.

  • In Firefox, type 'about:config' in the address bar
  • If prompted, accept any warnings
  • Right-click to create a new boolean value, and enter 'security.enterprise_roots.enabled' as the Name
  • Set the value to 'true'

Credits to this post for this info.

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay