Skip to content

Instantly share code, notes, and snippets.

@ctigeek
Last active September 22, 2017 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctigeek/5eec9ff367cfb3e31ecbf57266cb40e1 to your computer and use it in GitHub Desktop.
Save ctigeek/5eec9ff367cfb3e31ecbf57266cb40e1 to your computer and use it in GitHub Desktop.
Configure self-hosted app for HTTPS
## the cert dns doesn't really matter since it's self-signed.
$certName = "myappname.local"
$cert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName $certName
Write-Host "Created self signed cert: $($cert.Thumbprint) "
$guid = [guid]::NewGuid()
$ip = "0.0.0.0:443"
"http add sslcert ipport=$ip certhash=$($cert.Thumbprint) appid={$guid} " | netsh
#### netsh http delete sslcert ipport=$ip
## netsh http show urlacl
##This will give anyone permission to listen. Change user to the user or group running the service.
"http add urlacl url=https://*:443/ user=Users" | netsh
##Note: the url above must match EXACTLY what you listen on.
## e.g. this will work:
## WebApp.Start<Startup>("https://*:443/")
## these will not:
## WebApp.Start<Startup>("https://+:443/")
## WebApp.Start<Startup>("https://10.10.10.5:443/")
## so you may need to change the url above to match what your app listens on.
## (The variable $ip above does not need to be so specific.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment