I have a problem with a connect from my asp.net core 2.2 project to an https site like there. I use IHttpClientFactory to create typed HttpClient in Startup.cs
services.AddHttpClient<ICustomService, MyCustomService>();
And I don't understand, how can I ignore SSL connection problems without creating HttpClient manually like this
using (var customHandler = new HttpClientHandler())
{
customHandler.ServerCertificateCustomValidationCallback = (m, c, ch, e) => { return true; };
using (var customClient = new HttpClient(customHandler)
{
// my code
}
}
Use ConfigureHttpMessageHandlerBuilder
:
services.AddHttpClient<ICustomService, MyCustomService>()
.ConfigureHttpMessageHandlerBuilder(builder =>
{
builder.PrimaryHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (m, c, ch, e) => true
};
});