I thought of using HttpClientFactory but I need to attach the certificate while making a call Currently, I am using HttpClient, But don't know how to attach the certificate.
Below is the httpClient code:
HttpClientHandler httpClientHandler = new HttpClientHandler
{
SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12,
ClientCertificateOptions = ClientCertificateOption.Manual
};
httpClientHandler.ClientCertificates.Add(CertHelper.GetCertFromStoreByThumbPrint(_Settings.MtlsThumbPrint, StoreName.My, _Settings.IgnoreCertValidChecking));
httpClientHandler.ServerCertificateCustomValidationCallback = OnServerCertificateValidation;
HttpClient _client = new HttpClient(httpClientHandler)
{
Timeout = TimeSpan.FromMinutes(1),
BaseAddress = new Uri(_Settings.BaseUrl)
};
So, how to convert the above httpClient to HttpClientFactory?
Any help would be appreciated.