I'm trying to replicate the normal certificate validation for anything other than requests to localhost
public static readonly HttpClient _httpClient = new HttpClient(new HttpClientHandler()
{
AllowAutoRedirect = false,
MaxConnectionsPerServer = int.MaxValue,
UseCookies = false,
ServerCertificateCustomValidationCallback = ValidateLocalhostCertificate
});
private static bool ValidateLocalhostCertificate(HttpRequestMessage arg1, X509Certificate2 arg2, X509Chain arg3, SslPolicyErrors arg4)
{
if (arg1.RequestUri.Host == "127.0.0.1")
{
return true;
}
else
{
// default validation
}
}
I'm writing an ASP.NET Core application using this answer to reverse proxy requests made from specific subdomains to local services (e.g. 1.mywebsite.com goes to 127.0.0.1:1001, 2.mywebsite.com goes to 127.0.0.1:1002, etc.)
PLEASE don't suggest IIS URL rewrites or any other method for doing this
I'm assuming that client => mywebsite over 443 is secure, and the only 'unsecure' bit using the answer linked above would be happening locally on the server when it ignores invalid certificates to the local services (which all run strictly on https, something I can't change) - if this is untrue please correct me!
I've tried scouring the core source code but I'm struggling to find how HttpClient typically validates certificates