Skip to content

Instantly share code, notes, and snippets.

@camieleggermont
Last active March 29, 2025 04:03
Show Gist options
  • Select an option

  • Save camieleggermont/5b2971a96e80a658863106b21c479988 to your computer and use it in GitHub Desktop.

Select an option

Save camieleggermont/5b2971a96e80a658863106b21c479988 to your computer and use it in GitHub Desktop.

Revisions

  1. camieleggermont revised this gist May 4, 2017. No changes.
  2. camieleggermont revised this gist May 4, 2017. No changes.
  3. camieleggermont created this gist May 4, 2017.
    19 changes: 19 additions & 0 deletions UpdateIISExpressCertificate.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    $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()