2010-10-15 37 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