WCF传输与https通信与证书问题

时间:2014-06-24 10:05:07

标签: c# web-services wcf iis ssl

我在服务器上的IIS中托管了一个Web应用程序,该服务器与安装在同一服务器上的Web服务进行通信。 Web Service作为标准服务安装,而不是通过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添加任何额外配置?

我尝试过在本地添加证书,但它对我来说很好。

1 个答案:

答案 0 :(得分:0)

您的SecurityProtocolType可能未启用(来自Windows注册表)。 如果你也得到这个:

System.IO.IOException: Unable to read data from the transport connection

尝试以下协议类型之一:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;   // Tls, Tls11, or Tls12