【发布时间】:2019-07-31 05:37:46
【问题描述】:
我在从我的 asp.net core 2.2 项目连接到像 there 这样的 https 站点时遇到问题。我使用 IHttpClientFactory 在 Startup.cs 中创建类型化的 HttpClient
services.AddHttpClient<ICustomService, MyCustomService>();
而且我不明白,如果不像这样手动创建 HttpClient,我怎么能忽略 SSL 连接问题
using (var customHandler = new HttpClientHandler())
{
customHandler.ServerCertificateCustomValidationCallback = (m, c, ch, e) => { return true; };
using (var customClient = new HttpClient(customHandler)
{
// my code
}
}
【问题讨论】:
标签: c# ssl asp.net-core httpclient