【问题标题】:The request was aborted: Could not create SSL/TLS secure channel. | System.Net.WebException请求被中止:无法创建 SSL/TLS 安全通道。 | System.Net.WebException
【发布时间】:2017-01-18 13:21:00
【问题描述】:

我的 webApi 在其中使用了第三方 web api 服务。问题是它在我的本地机器和 Azure Web 服务中完美运行。但是当我将此解决方案传输到 Azure Vm 实例时,会出现此错误。我已经安装了与该第 3 方 Web api 相关的正确证书并在 HttpClient 注册并尝试使用

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;

但它给出了同样的错误。我不知道确切的错误是什么。请问有人可以帮忙吗?

【问题讨论】:

  • 您使用的是什么第三方 Web API?您能否提供一些关于调用第三方 Web API 的关键代码,以便我们重现此问题。

标签: c# azure ssl asp.net-web-api virtual-machine


【解决方案1】:

据我了解,您可以参考以下方法来检查此问题:

1.利用https://www.ssllabs.com/ssltest/检查你方和第三方Web API支持的协议如下:

2.配置SecurityProtocolServerCertificateValidationCallback如下:

ServicePointManager.Expect100Continue = true;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
            | SecurityProtocolType.Tls11
            | SecurityProtocolType.Tls12
            | SecurityProtocolType.Ssl3;

另外,您可以参考类似的issue1issue2 了解更多详情。

【讨论】:

    猜你喜欢
    • 2016-04-28
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    • 2018-04-22
    • 2012-10-30
    相关资源
    最近更新 更多