当我尝试从我的 .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/