我们的核心服务器通过 https 调用多个不同服务器上的 soap 网络服务,以确认交易已完成。
代码是 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 错误。
在谷歌搜索问题后,我尝试添加以下行(当然不适合生产,但我想测试):
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 中发生了一些变化,这意味着只有使用 TLS 1.0(或更好,大概)才能接受出站 https 连接。
在我们的案例中,当目标服务器上的配置更改为接受 TLS 时,问题得到解决。感觉应该有一种方法可以改变我的程序以强制它使用 SSL,但我还没有找到它。
关于.net - 无法为 SOAP 调用的 SSL/TLS 建立安全通道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3983230/