How to allow all https regardless of validity in .NET Core HttpClient?
I found the solution:
var httpClientHandler = new HttpClientHandler();
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true; // DEBUGGING ONLY
var httpClient = new HttpClient(httpClientHandler);
Although it is still unclear to me why the certificate is not considered valid after running dotnet dev-certs https --trust.
Use the sample below from here
var httpClientHandler = new HttpClientHandler();
// Return `true` to allow certificates that are untrusted/invalid
httpClientHandler.ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
var httpClient = new HttpClient(httpClientHandler);