HTTP Get 请求错误“身份验证失败,因为远程方已关闭传输流。”

Posted

技术标签:

【中文标题】HTTP Get 请求错误“身份验证失败,因为远程方已关闭传输流。”【英文标题】:HTTP Get request error "Authentication failed because the remote party has closed the transport stream." 【发布时间】:2016-06-24 07:07:35 【问题描述】:

当我尝试从我的 .net 3.5 winform 应用程序调用 rest webservice(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)`

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

XElement response = XElement.Load(url);

【问题讨论】:

【参考方案1】:

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

【讨论】:

以上是关于HTTP Get 请求错误“身份验证失败,因为远程方已关闭传输流。”的主要内容,如果未能解决你的问题,请参考以下文章

推送通知上的错误“身份验证失败,因为远程方已关闭传输流”

HttpWebrequest 失败,内部异常身份验证失败,因为远程方已关闭传输流

APNS SSlStream 身份验证失败,因为远程方已关闭传输流

C# 身份验证失败,因为远程方已关闭传输流

iOS (APN) - 身份验证失败,因为远程方已关闭 C# 中的传输流

普通用户的“身份验证失败,因为远程方已关闭传输流”