Create self signed certificate for testing localhost and have it accepted by the browsers Create self signed certificate for testing localhost and have it accepted by the browsers windows windows

Create self signed certificate for testing localhost and have it accepted by the browsers


I was trying to do a similar thing and did get the following to work:

New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname localhost -FriendlyName "Dev localhost" -NotAfter (Get-Date).AddMonths(240) -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1")

The 'NotAfter' param extends the cert to 20 years.The 'TextExtension' param configures the cert for 'Server Authentication' only. Without this, it defaults to Client Auth + Server Auth. I haven't researched, but the Client Auth seems to cause an issue (which is odd since most online examples don't mention it; I only found one that did).

This will create the cert in both the LocalComputer\Personal & LocalComputer\Intermediate Certification Authority. It also allows you to select the cert in IIS.

In order to actually run the site, the cert needs to get into the Trusted Root Certification Authority. To accomplish this, you can either export/import the cert or nav to the site in IE, click on the red security area and work your way thru the screens to import the cert. The link above shows the import/export approach.

Final notes:

  • I had to close/re-open IE (11.726.15063) to get the security prompt to go away despite IE telling me that the cert was installed.
  • My site was working fine in chrome (62) after the security warning cleared in IE.
  • I was using localhost and a non-standard port for my site, not a DNS name. Everything seemed fine.

HTH