Skip to content

Instantly share code, notes, and snippets.

@jlouros
Created November 24, 2017 17:19
Show Gist options
  • Save jlouros/8c17e45cf9c8a2286a78cfd8f6bada5f to your computer and use it in GitHub Desktop.
Save jlouros/8c17e45cf9c8a2286a78cfd8f6bada5f to your computer and use it in GitHub Desktop.
Create self-signed certificate for localhost
#Replace "Subject" with CN (Common Name) and/or SAN (Subject Alternative Name)
New-SelfSignedCertificate -DnsName localhost -CertStoreLocation Cert:\LocalMachine\My
#Replace "Password" with your password.
$CertPassword = ConvertTo-SecureString -String "yourpassword" -Force –AsPlainText
#Replace "Thumbprint" with certificate Thumbprint and "path-to-pfx" the location where the certificate PFX will be saved.
Export-PfxCertificate -Cert cert:\LocalMachine\My\{thumbprint} -FilePath {path-to-cert-output.pfx} -Password $CertPassword
# open IIS manager
# set website binding
# use 'https', Host name: 'locahost', select your localhost certificate
# [Ctrl] + [r]
# mmc.exe
# [Ctrl] + [m]
# select 'Certificates', 'Add >', 'Computer account', 'Next >', 'Finish', 'OK'
# from 'Certificates' navigate to 'Personal/Certificates'
# right-click 'localhost' and 'Copy'
# from 'Certificates' navigate to 'Trusted Root Certification Authorities/Certificates'
# right-click, 'Paste'
@jlouros
Copy link
Author

jlouros commented Nov 24, 2017

if you have multiple 'localhost' certificates, delete them and try again


references:
https://www.youtube.com/watch?v=zTlc5Z59FpA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment