c# - WCF 传输与证书问题的 https 通信

标签 c# web-services wcf iis ssl

我在服务器上的 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/

相关文章:

c# - 在 resharper intellisense 中显示枚举整数值

c# - 如何解释 WP7 中滚动查看器偏移量的变化?

c# - 使用 JavaScript 连接到 .NET 服务器

.net - 查看原始 XML 请求

c# - 从 Excel 2010 调用 Web 服务

c# - 连接 byte[] 的 C# 列表

c# - 按父项和子项排列的订单列表

java - 从spring-boot中的properties.yml文件中读取字符串数组数据

java - 旧版应用程序可在同一服务器或通过 ws 访问

Java 和 WCF DateTime 的互移植性问题