c# - SSL 握手从 asp.net 应用程序失败 - 在浏览器中工作

标签 c# asp.net ssl

我正在尝试使用 System.Net.Http.HttpClient(使用 GetStringAsync)执行一个简单的获取请求。从我的 webapi asp.net 应用程序完成时请求失败,但它在浏览器和 postman 中正常工作。

请求失败,显示Authentication failed because the remote party has closed the transport stream.

Note: It works correctly when doing get request to other servers using TLS.

我使用以下内容来确认问题出在 ssl 上。使用这两行可以使请求有效,但显然禁用证书验证不是真正的解决方案。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

I tested the server using https://www.ssllabs.com and it seems that everything is working correctly on there. It supports TLS 1.1 and 1.2.

为了了解发生了什么,我查看了 wireshark 中的包,但由于我对 ssl 了解不多,所以我学的不多。查看来自浏览器请求的包,我可以看到它使用的是 TLS 1.2 协议(protocol)并且握手看起来是正确的。 下图显示了客户端发起两个单独的 ssl “ClientHello's”。由于某种原因,服务器没有响应 SSL 握手响应。

Wireshark ssl handshake

希望有人能帮我弄清楚这是怎么回事。

最佳答案

I tested the server using https://www.ssllabs.com and it seems that everything is working correctly on there. It supports TLS 1.1 and 1.2.

您的客户端仅进行 TLS 1.0 握手。如果服务器仅支持 TLS 1.1 和 TLS 1.2 但不支持 TLS 1.0,则连接将失败。由于现代浏览器都支持 TLS 1.2 浏览器。

关于c# - SSL 握手从 asp.net 应用程序失败 - 在浏览器中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34333746/

相关文章:

c# - 在 Nest (ElasticSearch) 中聚合子/嵌套对象

ruby-on-rails - 创建新 Rails 项目时出现 OpenSSL 错误

c++ - 从支持 OpenSSL 支持的源代码构建 Qt 静态

c# - 如何检测 1 个 Entity Framework 对象的变化

c# - WCF 试图公开一个 nettcp 端点; TCP 错误代码 10061 : No connection could be made because the target machine actively refused it

asp.net - 使用 ServiceStack 检查请求 header

c# - 如何获取传递给函数的变量的名称?

javascript - 没有 HTTPS 的带有 Google Hangout API 的本地 Javascript 文件

c# - WCF:使用 TransferMode=Streamed over netTcpBinding 将文件传输到服务器时,对客户端的响应延迟

javascript - React.createElement 抛出组件未定义