小编Ale*_*nov的帖子

通过 IHttpClientFactory 忽略 SSL 连接错误

我在从我的 asp.net core 2.2 项目连接到像那里这样的 https 站点时遇到问题。我使用 IHttpClientFactory 在 Startup.cs 中创建类型化的 HttpClient

services.AddHttpClient<ICustomService, MyCustomService>();
Run Code Online (Sandbox Code Playgroud)

我不明白,如何在不像这样手动创建 HttpClient 的情况下忽略 SSL 连接问题

using (var customHandler = new HttpClientHandler())
{
    customHandler.ServerCertificateCustomValidationCallback  = (m, c, ch, e) => { return true; };
    using (var customClient = new HttpClient(customHandler)
    {
        // my code
    }
}
Run Code Online (Sandbox Code Playgroud)

c# ssl httpclient asp.net-core

6
推荐指数
1
解决办法
1391
查看次数

标签 统计

asp.net-core ×1

c# ×1

httpclient ×1

ssl ×1