我有一个 MVC 5 Web 应用程序,我需要使用 SSL 来运行其中的部分(登录、帐户管理等)。我为 Web 项目启用了 SSL,更改了
applicationhost.config
: 中的绑定
<bindings>
<binding protocol="http" bindingInformation="*:80:example.com" />
<binding protocol="https" bindingInformation="*:443:example.com" />
</bindings>
但是,当我重新启动 IIS Express 并运行该站点时,它会将 SSL 端口覆盖为 44300。有什么办法让它保持在 443 吗?
netsh http show sslcert
。在输出中搜索 port 44300
条目并复制 certhash
和 appID
值。
删除 44300 的条目:
netsh http delete sslcert ipport=0.0.0.0:44300
使用步骤 1 中的 certhash 和 appID 添加端口 443 的新条目:
netsh http add sslcert ipport=0.0.0.0:443 certhash=<certhash> appid=<appid>
。
如果您在 Powershell 中运行此命令,则需要将参数用单引号引起来,因此上面步骤 3 中的命令将变为
netsh http add sslcert 'ipport=0.0.0.0:443' 'certhash=<certhash>' 'appid=<appid>'
在http.sys中配置条目后,需要重新启动http服务才能使更改生效。
net stop http
net start http
从 Powershell 中,您可以像这样重新启动服务:
Restart-Service http