Android HttpClientHandler.ClientCertificates fix (#2270)

This commit is contained in:
James Newton-King 2018-05-17 06:25:40 +12:00 committed by Andrew Stanton-Nurse
parent 95f543848c
commit e1a22b315d
1 changed files with 8 additions and 2 deletions

View File

@ -486,10 +486,16 @@ namespace Microsoft.AspNetCore.Http.Connections.Client
{
httpClientHandler.CookieContainer = _httpConnectionOptions.Cookies;
}
if (_httpConnectionOptions.ClientCertificates != null)
// Only access HttpClientHandler.ClientCertificates if the user has configured client certs
// Mono does not support client certs and will throw NotImplementedException
// https://github.com/aspnet/SignalR/issues/2232
var clientCertificates = _httpConnectionOptions.ClientCertificates;
if (clientCertificates?.Count > 0)
{
httpClientHandler.ClientCertificates.AddRange(_httpConnectionOptions.ClientCertificates);
httpClientHandler.ClientCertificates.AddRange(clientCertificates);
}
if (_httpConnectionOptions.UseDefaultCredentials != null)
{
httpClientHandler.UseDefaultCredentials = _httpConnectionOptions.UseDefaultCredentials.Value;