我的 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.配置SecurityProtocol
和ServerCertificateValidationCallback
如下:
ServicePointManager.Expect100Continue = true;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
| SecurityProtocolType.Ssl3;
关于c# - 请求被中止 : Could not create SSL/TLS secure channel. |系统.Net.WebException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41720564/