c# - HTTP Get请求错误 "Authentication failed because the remote party has closed the transport stream."

标签 c# web-services rest ssl tls1.2

当我尝试从我的 .net 3.5 winform 应用程序调用 rest web 服务 (HTTP get) 时,出现以下错误:

     `Authentication failed because the remote party has closed the transport stream. 
StackTrace:    at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
       at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.ConnectStream.WriteHeaders(Boolean async)`

从浏览器运行时请求运行良好。 那么,问题是否与服务器使用.net 3.5 不支持的更高 tls 协议(protocol)有关? 这是我调用网络服务的代码:

XElement response = XElement.Load(url);

最佳答案

是的,最有可能的原因是网络服务器 TLS 1.2。如果您无法升级您的 .net 框架,那么这可能会有所帮助:https://github.com/juhovh/AaltoTLS
顺便说一句,我没有使用过这个第三方代码,也不认可它 - 它的适用性由你决定。

关于c# - HTTP Get请求错误 "Authentication failed because the remote party has closed the transport stream.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38007534/

相关文章:

java - Android KSoap 错误

rest - 具有预配置授权的 OAuth 安全性

api - CouchDB 作为 Restful API 层?

python - Django 1.8 PUT和DELETE方法简单实现

c# - 即使在输入有效凭据后,Windows 身份验证弹出窗口仍会继续出现

c# - 如何编写使用从 C# 创建的临时表的存储过程

c# - 更改 c/c++ dll 中的参数

c# - 从 C# 调用 soap 服务

c# - 如何在 C# 中执行表 SP

java - 从 Java Web 服务启动外部进程的最佳方式?