The underlying connection was closed: An unexpected error occurred on a send

操做系統是Windows Server 2003 x64 SP2,使用Framework 4.0,在使用WebClient訪問某些特定的HTTPS站點時,會引起異常:windows


Unhandled Exception: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.

   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)瀏覽器

   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)async

   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)ide

   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, Boolean ignoreSyncCtx)ui

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)spa

   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)操作系統

   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)firefox

   at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)

   at System.Net.ConnectStream.WriteHeaders(Boolean async)

   --- End of inner exception stack trace ---


The underlying connection was closed: An unexpected error occured on a send.

基礎鏈接已關閉,發送時發生錯誤


從信息上看是ssl認證失敗,此錯誤並非全部https站點都出現,另外報錯的站點,用瀏覽器或是wget一類的工具訪問都正常。挑了一個報異常的網站,查看一下鏈接信息(用的firefox):

wKioL1kUOX3jhmaoAABD8ZLCWG0047.png


使用了比較新的TLS1.2,開始懷疑操做系統不支持,因而開始翻微軟網站,找到一個頁面:

https://support.microsoft.com/en-us/help/948963/an-update-is-available-to-add-support-for-the-tls-rsa-with-aes-128-cbc-sha-aes128-sha-and-tls-rsa-with-aes-256-cbc-sha-aes256-sha-aes-cipher-suites-in-windows-server-2003


確認了Server 2003確實不支持,須要打個hotfix,以後再嘗試就一切正常了。有遇到相同問題的同窗能夠參考一下。

相關文章
相關標籤/搜索