.Net Web 引用 SSL 错误

标签 .net web-services soap ssl

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

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

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

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

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

最佳答案

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

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

关于.Net Web 引用 SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3943589/

相关文章:

c# - Image.GetThumbnailImage 方法和质量

.net PDF 查看器控件

c# - 检查运行我的代码需要什么版本的 .NET

android - 如何在Android上托管REST Web服务?

web-services - WS* 与 REST = 类(class)的马匹...或不?

java - 在Weblogic中解析SOAP调用的XML响应

.net - 如何在没有互联网连接的情况下安装 NuGet 包?

java - Apache CXF 拦截器覆盖内容类型

web-services - 什么是 API Web 服务,您如何创建它们以及为什么?

angular - 使用来自 Angular 的客户端证书调用 SOAP 服务