/// <summary> /// Set the client certificate provider (NetStandard implementation) /// </summary> /// <param name="provider">The provider for client certificates on this platform</param> public virtual void SetClientCertificates(Abstractions.IClientCertificateProvider provider) { ClientCertificates.Clear(); if (provider is IClientCertificateProvider netProvider) { ClientCertificates.AddRange(netProvider.Certificates); } }
protected override async Task <HttpResponseMessage> SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { string serverName = request.RequestUri.Host; if (ClientCertificates.Contains(_certMap[serverName])) { try { var response = await base.SendAsync(request, cancellationToken); return(response); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); throw; } } else { ClientCertificates.Clear(); ClientCertificates.Add(_certMap[serverName]); try { var response = await base.SendAsync(request, cancellationToken); return(response); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); throw; } } }