【问题标题】:.Net Web Reference SSL Error.Net Web 参考 SSL 错误
【发布时间】:2010-10-15 15:15:27
【问题描述】:

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

客户端的父类是 SoapHTTPClientProtocol,如果这有什么不同的话。

我无法修改服务器的证书。是否有接受证书的编程方式?
谷歌搜索我发现了几个对 ServicePointManager 类的引用,但没有一个足够全面,以至于我理解如何使用它。

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

还有其他人遇到过这个错误吗?

【问题讨论】:

    标签: .net web-services soap ssl


    【解决方案1】:

    在调用服务之前尝试调用它:

    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;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-19
      • 1970-01-01
      • 2012-09-18
      • 2016-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多