Skip to content

Creating a self-signed certificate on a Windows development PC

To get around the dreaded ERR_CERT_COMMON_NAME_INVALIDĀ error, you need to create (properly) a self-signed SSL certificate. Or you have to apply a paid-for cert, but let’s go free for now!

A version of these instructions first appeared on this website and are reproduced here for posterity.

Powershell – generate the certificate

  1. Open up Powershell and Run it as an Administrator.
  2. Copy and paste the following command into Powershell and then edit the mydomain.local bit with your local development machine’s URL.
New-SelfSignedCertificate -DnsName "mydomain.local" -CertStoreLocation "cert:\LocalMachine\My"

This will create a self signed certificate for you to use, but before you can use it, we need to move it into the list of Trusted Root Certification Authorities Certificates.

Certificate Manager – trust the certificate

  1. Open up Managed Computer Certificates by hitting the Windows key and then typing Cert.
  2. Click on ‘Manage Computer Certificates’
  3. Under Personal, click on the Certificates folder
  4. Find the certificate you created
  5. Right click on it and choose ‘Copy’
  6. Then under Trusted Root Certification Authorities right click on the Certificates folder and choose ‘Paste’.

This “trusts” the certificate, but only on your machine.

IIS – use the certificate

  1. Open IIS.
  2. Find the website that you need to use the certificate that matches your edit to the command in the Powershell command.
  3. Right-click the website and choose Edit Bindings.
  4. Find the https line and edit it, or create the binding (by entering the website URL and requiring server name indication).
  5. Select your new SSL certificate from the drop down and click OK.

You should now be set. If you’ve visited the dev URL that day, you might find you still get Not Secure in Chrome, for example, but thatĀ should clear itself!

Published inweb hostingWindows