Forked from camieleggermont/UpdateIISExpressCertificate.ps1
Created
June 17, 2017 06:50
-
-
Save manojkulkarni30/8a2e72976b2b9ff05cb271a4ec5f90c0 to your computer and use it in GitHub Desktop.
This powershell script generates a new certificate, removes the old certificate assignments from the IISExpress ssl ports and adds the newly generated one. The certificate is also copied over to the Trusted Root Certificate Authorities.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cert = New-SelfSignedCertificate -DnsName "localhost", "localhost" -CertStoreLocation "cert:\LocalMachine\My" -NotAfter (Get-Date).AddYears(5) | |
$thumb = $cert.GetCertHashString() | |
For ($i=44300; $i -le 44399; $i++) { | |
netsh http delete sslcert ipport=0.0.0.0:$i | |
} | |
For ($i=44300; $i -le 44399; $i++) { | |
netsh http add sslcert ipport=0.0.0.0:$i certhash=$thumb appid=`{214124cd-d05b-4309-9af9-9caa44b2b74a`} | |
} | |
$StoreScope = 'LocalMachine' | |
$StoreName = 'root' | |
$Store = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $StoreName, $StoreScope | |
$Store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite) | |
$Store.Add($cert) | |
$Store.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment