Zar*_*ani 10 .net vb.net ssl wcf soap
我们的核心服务器通过https在多个不同的服务器上调用soap Web服务,以确认事务已完成.
代码是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)
Run Code Online (Sandbox Code Playgroud)
相关的代码片段似乎是:
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)
Run Code Online (Sandbox Code Playgroud)
从我的个人笔记本电脑(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
Run Code Online (Sandbox Code Playgroud)
结果是一样的.SSL错误仍然发生.
其他地方建议根证书没有在呼叫机器上正确安装,但新服务器和旧回调服务器都使用Go Daddy颁发的证书,所以我不认为这是这种情况.
小智 6
在客户端,尝试:
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
Run Code Online (Sandbox Code Playgroud)