Dot-Net
無法為 SOAP 呼叫建立 SSL/TLS 安全通道
我們的核心伺服器正在多個不同伺服器上通過 https 呼叫一個肥皂網路服務,以確認交易已經完成。
該程式碼是 dotnet 3.5 (vb),適用於我們設置的各種回調服務,直到我們剛剛將一個新服務移入生產環境,它拒絕通信,並出現以下錯誤:
Unhandled Exception: System.ServiceModel.Security.SecurityNegotiationException: Could not establish secure channel for SSL/TLS with authority 'www.xyzzy.com'. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)相關的程式碼似乎是:
Dim epAddr As New System.ServiceModel.EndpointAddress(sys.CallbackAddress) Dim bind As New System.ServiceModel.BasicHttpBinding(ServiceModel.BasicHttpSecurityMode.Transport) _svc = New CallbackSvc.XyzzyCallbackSoapClient(bind, epAddr)在我的個人筆記型電腦 (WinXP) 上,我可以執行程式碼,它可以毫無問題地連接到新伺服器。
從主伺服器(呼叫所有回調服務)(Windows Server Enterprise Service Pack 1),程式碼總是會導致上述 SSL 錯誤。
在Google搜尋問題後,我嘗試添加以下行(當然不適合生產,但我想測試):
System.Net.ServicePointManager.ServerCertificateValidationCallback = Function(se As Object, cert As System.Security.Cryptography.X509Certificates.X509Certificate, chain As System.Security.Cryptography.X509Certificates.X509Chain, sslerror As System.Net.Security.SslPolicyErrors) True結果是一樣的。SSL 錯誤仍然發生。
其他地方表明呼叫機器上沒有正確安裝根證書,但是新伺服器和舊回調伺服器都使用 Go Daddy 頒發的證書,所以我認為這裡不是這種情況。
事實證明,這是生產“核心”伺服器(呼叫服務的伺服器)和目標伺服器(託管服務)之間的互動,不共享可接受的 https 算法。 wfetch在診斷問題方面非常有幫助。
事實證明,目標伺服器沒有設置為接受 TLS 1.0,只接受了 SSL 3.0。
顯然,Windows 2008 Server 中發生了一些變化,這意味著出站 https 連接只能使用 TLS 1.0(或者可能更好)。
在我們的例子中,當目標伺服器上的配置更改為接受 TLS 時,問題就解決了。感覺應該有一種方法可以改變我的程序以強制它使用 SSL,但我還沒有找到它。