Problem statement
What is the best way to dynamically add a client certificate to a HttpClient in C#? I have an application that needs to call the same endpoint with different client certificates (We are calling an API on behalf of our clients).
Scenario:
We are not able to use named HttpClients because our customer base will grow and shrink dynamically. What I had in mind was to create a HttpClientFactory so you could do the following. Doing so creates new problems e.g. socket exhaustion.
var factory = new HttpClientFactory()
var certificate = new X509Certificate2();
HttpClient customerClient = factory.CreateClient(certificate)
Research: