Since this question is tagged with IIS and I can’t find a good answer on how to get a trusted certificate I will give my 2 cents about it:

First use the command in PowerShell as administrator:

New-SelfSignedCertificate -DnsName "localhost" -CertStoreLocation "cert:\LocalMachine\My" -NotAfter (Get-Date).AddYears(100)

Added Valid to 100 years so that the cert for localhost hopefully does not expire. You can use -NotAfter (Get-Date).AddMonths(24) for 24 months if you want that instead or any other value.

This is good but the certificate is not trusted and will result in the following error. It is because it is not installed in Trusted Root Certification Authorities.

Solve this by starting mmc.exe.

Then go to:

File -> Add or Remove Snap-ins -> Certificates -> Add -> Computer account -> Local computer. Click Finish.

Expand the Personal folder and you will see your localhost certificate:

Copy the certificate into Trusted Root Certification Authorities - Certificates folder.

The final step is to open Internet Information Services (IIS) Manager or simply inetmgr.exe. From there go to your site, select Bindings... and Add... or Edit.... Set https and select your certificate from the drop down.

Your certificate is now trusted:

Mehran Hematyar (Hemmatyar)

Ph.D (c) Mikrotik Cisco Official Trainer CyberSecurity Activist AzTU - UNEC - BMU - BANM Senior Lecturer

Leave a Reply

Your email address will not be published. Required fields are marked *