How to add ServerCertificateCustomValidationCallback in a HttpClient Injection on NET6?
I'm stuck on below program.cs:
builder.Services.AddHttpClient<ITest, Test>(c =>
{
c.BaseAddress = new Uri("https://iot.test.com/api");
c.DefaultRequestHeaders.Accept.Add(new
MediaTypeWithQualityHeaderValue("application/json"));
c.Timeout = TimeSpan.FromMinutes(20);
}).ConfigureHttpClient((c) =>
{
new HttpClientHandler()
{
ServerCertificateCustomValidationCallback += (sender, cert, chain,
sslPolicyErrors) =>
{
return sslPolicyErrors == SslPolicyErrors.None;
};
};
});
the VS2022 Community IDE keeps saying ServerCertificateCustomValidationCallback doesn't exist in the current context