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 from @AuriRahimzadeh in PowerShell as administrator:
New-SelfSignedCertificate -DnsName "localhost" -CertStoreLocation "cert:\LocalMachine\My"
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: