You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何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的输出截图:
netsh http show sslcert输出

以及certlm的显示截图(第二个标签页确认其指纹与上述一致):
certlm证书信息


内容的提问来源于stack exchange,提问作者Kiran Ramaswamy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 01:44:57