Question
Why will my HttpClient instance not use my provided client certificate for mutual auth?
Background
I'm using HttpClient to do mutual TLS. As the client, I'm adding a client certificate to a WebRequestHandler and then using that handler in the new HttpClient.
The certificate is not installed on my machine. I've successfully loaded it into the handler and can see it when debugging (the password is correct, too).
I'm testing against a couple of different test domains
- https://client.badssl.com/ - this looks for client auth using the cert found here. This is the cert I'm currently using
- https://prod.idrix.eu/secure/ - this one simply spits back out any client cert presented.
Both testing apps are showing no cert is being sent.
Code
var clientCert = new X509Certificate2("badssl.pem", "badssl.com");
var webHandler = new WebRequestHandler();
webHandler.ClientCertificates.Add(clientCert);
var httpClient = new HttpClient(webHandler);
var result = await (await httpClient.GetAsync(uri)).Content.ReadAsStringAsync();