【发布时间】:2017-03-06 05:20:47
【问题描述】:
我已经实现了一种使用 APS.NET 核心 (System.Net.HttpWebRequest) 从 REST API 请求(基于 SSL 的请求:https://)获取响应的方法。
我需要忽略获取WebResponse 时发生的证书错误。我参考了很多博客,得到了使用ServicePointManager 的解决方案,并在下面的代码中使用了这个
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
但在 ASP.NET 核心中不支持ServicePointManager。因此,请仅通过HttpWebRequest 而非HttpClient 帮助我解决此问题。
【问题讨论】:
标签: c# https asp.net-core self-signed system.net.httpwebrequest