为何IIS Express需每4小时重新绑定自签名证书才能访问localhost?
IIS Express本地证书每4小时失效问题求助
我仅知道以下操作有效,但不懂原理:使用Visual Studio 2022运行IIS Express时,我需要每约4小时重新运行下方脚本,并将新生成的证书拖入Trusted Root Certificate Authorities\Certificates,浏览器才能识别localhost;不执行的话,浏览器会提示无法识别目标地址。
# port and appId are any randomly chosen port or guid $name = 'localhost' $port = 12345 $appId = '626feeb6-1ee1-4670-8d38-80b8139fe8ce' Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Subject -eq 'CN=' + $name } | Remove-Item $thumb=(New-SelfSignedCertificate -DnsName $name -CertStoreLocation cert:\LocalMachine\My).Thumbprint.ToLower() Invoke-Expression "netsh http delete sslcert ipport=0.0.0.0:$port" Invoke-Expression "netsh http add sslcert ipport=0.0.0.0:$port appid='{$appId}' certhash=$thumb"
请问有人知道这一现象的原因吗?
补充信息1:
为便于排查,附上netsh http show sslcert ipport=0.0.0.0:$port的输出截图:
以及certlm的显示截图(第二个标签页确认其指纹与上述一致):
内容的提问来源于stack exchange,提问作者Kiran Ramaswamy
相关产品推荐
相关产品推荐

