c# - 请求被中止 : Could not create SSL/TLS secure channel. |系统.Net.WebException

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

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

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

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

最佳答案

据我了解,您可以引用以下方法排查该问题:

1.杠杆https://www.ssllabs.com/ssltest/检查您端和第三方 Web API 支持的协议(protocol),如下所示:

2.配置SecurityProtocolServerCertificateValidationCallback如下:

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

另外,你可以引用这个类似的issue1issue2了解更多详情。

关于c# - 请求被中止 : Could not create SSL/TLS secure channel. |系统.Net.WebException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41720564/

相关文章:

c# - System.Net.Http.HttpClient 添加 Request-Id header

asp.net - Azure:如何在一个虚拟网络中将一项云服务与其他云服务连接

php - readfile() 由于 SSL 而失败

security - 如何检查我的 Web 服务器上的 SSL 漏洞?

c# - VS 项目创建中的 "Enable Docker"是只添加了 docker 文件还是有更多的魔力?

c# - 静态构造函数重载?

c# - 比较数据库中的日期时间时,“LIKE%”在更新查询中不起作用

Azure kubernetes - java spring应用程序和托管身份来访问 key 保管库?

azure - qnamaker 与 LUIS

ios - 远程加载客户端证书的iOS如何实现SSL相互认证?