2010-10-15 36 views
0

在需要HTTPS连接的服务器上对SOAP服务使用Visual Studio“Web引用”时出现错误: “底层连接已关闭:无法建立信任关系SSL/TLS安全通道“。.Net Web引用SSL错误

客户端的父类是SoapHTTPClientProtocol,如果有任何区别的话。

我不能修改服务器的证书。是否有程序接受证书的方式?
Googling around我发现了一些对ServicePointManager类的引用,但没有足够全面的了解我如何使用它。

http://support.microsoft.com/kb/915599

有没有其他人遇到这个错误?在调用服务之前

回答

0

尝试调用此:

ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications); 

,并把这个回调方法:

private static bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) 
    { 
     return true; 
    } 
+0

,完美的工作!非常感谢Brendan。 – Apathor 2010-10-15 16:46:03