windows - 由于证书服务器证书未使用 HTTP.SYS 正确配置而导致的 SSL 定期崩溃

标签 windows wcf ssl certificate

我正在尝试在装有 Windows Server 2012 的服务器上安装自托管 WCF 服务。 我正在执行以下步骤:

  1. 使用 mmc 导入我的 pfx 文件
  2. 运行“netsh http 添加 sslcert ipport=0.0.0.0:49000 certhash=e09280ded2322eb858b38b3250e1a488f797b269 appid={4dc3e181-e14b-4a21-b022-59fc669b0914}”

  3. 安装我的服务并启动它

起初它运作良好。但是几个小时后,ssl 崩溃了,我只能在客户端收到错误消息,如下所示

An unhandled exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll. Additional information: An error occurred while making the HTTP request to https://servername:49000/WCFServiceName. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.

运行“netsh http delete sslcert ipport=0.0.0.0:49000” 并删除导入的pfx,然后重做step1和step 2可以使ssl重新工作,但是过几个小时还是会出现这个问题。

肯定不是SecurityProtocol的问题,因为我已经尝试添加了

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

请求之前。服务器和客户端都使用.Net Framework 4.5.2

我试过“netsh http show sslcert”,得到以下结果:

    IP:port                      : 0.0.0.0:49000
    Certificate Hash             : e09280ded2322eb858b38b3250e1a488f797b269
    Application ID               : {4dc3e181-e14b-4a21-b022-59fc669b0914}
    Certificate Store Name       : My
    Verify Client Certificate Revocation : Enabled
    Verify Revocation Using Cached Client Certificate Only : Disabled
    Usage Check                  : Enabled
    Revocation Freshness Time    : 0
    URL Retrieval Timeout        : 0
    Ctl Identifier               : (null)
    Ctl Store Name               : (null)
    DS Mapper Usage              : Disabled
    Negotiate Client Certificate : Disabled

我已经尝试删除端口 49000 上的 sslcert 绑定(bind),并在 IIS 中创建一个绑定(bind)到端口 49000 的空网站,然后让我的服务监听该端口。它第一次工作并持续了大约一个星期,然后才弹出相同的错误。

我应该从哪里开始定位和解决这个有线问题?

最佳答案

首先,我们应该确保证书私钥可以被WCF访问。 Network Service 帐户(或Everyone 帐户)应添加到证书READ/Writer 组中,然后我们使用相应的帐户运行应用程序(windows 服务或控制台?)。
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-make-x-509-certificates-accessible-to-wcf
其次,如您所知,TLS 版本需要操作系统和 Dotnetframework 支持,默认协议(protocol)版本为 ssl3.0/tls1.0(自动协商,无法配置)。我们最好使用最新的操作系统版本和.netframework4.7。我想这可能是通信不稳定的原因。 请引用以下文档。
https://learn.microsoft.com/en-us/dotnet/framework/network-programming/tls
如果问题仍然存在,请随时告诉我。

关于windows - 由于证书服务器证书未使用 HTTP.SYS 正确配置而导致的 SSL 定期崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56319090/

相关文章:

windows - 它在哪里创建 7zip 压缩文件

python - 如何在 Windows cmd 中传递 *.txt 之类的通配符参数

c++ - 我可以在没有虚拟微型端口驱动程序的情况下创建 VPN 应用程序吗?

wcf - 解决方案中的多个 WCF 项目与单个项目

c# - webrole 上的 Azure WCF 服务上基于 x509 证书的身份验证

windows - 创建 Oracle Wallet 以在 Windows 上存储数据库凭证

python - 如何让CMake在生成visual studio解决方案后执行一些脚本

javascript - 从 html 调用 wcf 服务总是转到错误函数。与 aspx 页面一起正常工作

c# - 如何通过 WCF 设置 SSL?

C++ 和 Curl : Failed to receive handshake, 需要更多数据