我在服务器上的 IIS 中托管了一个 Web 应用程序,该应用程序与安装在同一服务器上的 Web 服务进行通信。 Web 服务作为标准服务安装,而不是通过 IIS 安装。
该服务已启动并正在运行,我可以使用 https 在浏览器中导航到它。我使用 netsh 添加了证书: WCF with transport security via certificates
但是,当 Web 应用程序尝试调用对 Web 服务的调用时,出现以下错误:
An error occurred while making the HTTP request to https://TheServer/VehicleService/ConnectXml/1.0/https. 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.
我更深入地研究了这个错误,我发现了这个:
<ExceptionType>System.IO.IOException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.</Message>
<ExceptionType>System.Net.WebException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The underlying connection was closed: An unexpected error occurred on a send.</Message>
有谁知道可能导致此问题的原因是什么?我需要向 IIS 添加任何额外的配置吗?
我已尝试在本地添加证书,对我来说效果很好。
最佳答案
您的 SecurityProtocolType 可能未启用(来自 Windows 注册表)。 如果你也得到这个:
System.IO.IOException: Unable to read data from the transport connection
尝试以下协议(protocol)类型之一:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; // Tls, Tls11, or Tls12
关于c# - WCF 传输与证书问题的 https 通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24383798/