我想使用HttpClientFactory,但我需要在拨打电话时附加证书目前,我正在使用HttpClient,但不知道如何附加证书。
以下是 httpClient 代码:
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)
};
那么,如何将上面的 httpClient 转换为 HttpClientFactory 呢?
任何帮助,将不胜感激。