当我尝试从我的.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不支持? 这是我调用webservice的代码:
XElement response = XElement.Load(url);
答案 0 :(得分:0)
是的,最可能的原因是网络服务器TLS 1.2。如果您无法升级您的.net框架,那么这可能会有所帮助:https://github.com/juhovh/AaltoTLS
顺便说一句,我没有使用过这个第三方代码,也没有认可它 - 由你决定它的适用性。