I am trying to make HttpPost call to a web api which is protected via certificate. I am using named HttpClient and creating clients using HttpClientFactory.
services.AddHttpClient(clientName, (c) =>
{
c.BaseAddress = baseAddress;
}).ConfigurePrimaryHttpMessageHandler((sp) =>
{
// use sp and get cert
return new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,
SslProtocols = SslProtocols.Tls12,
ClientCertificates = { cert }
};
});
Now we fetch HttpClient instance using CreateClient call and using MultipartFormDataContent I make a Post request.
When I make this Post request sequentially I see not problem, when I make this request parallely on 5 differnent thread, Few call fails with 403 error. Making a GET call to same API on different endpoint in parallel doesn't translate in any error.
Any help on how can I troubleshoot this 403 error code when I make HttpPost call in parallel.
I looked at System.Net traces but unable to find what caused this.