I'm getting this error when using certificate based authentication with System.Net.Http.HttpClient in .Net Standard 2.0. This is not related to not using Tls1.2 as this answer would suggest.
var requestMessage = new HttpRequestMessage() {
RequestUri = new Uri(new Uri(_configuration.Endpoint), "someendpoint"),
Method = HttpMethod.Get
};
var handler = new HttpClientHandler {
ClientCertificateOptions = ClientCertificateOption.Manual,
SslProtocols = SslProtocols.Tls12,
};
handler.ClientCertificates.Add(certificate);
handler.CheckCertificateRevocationList = false;
// this is required to get around untrusted self-signed certs
handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true;
var client = new HttpClient(handler);
requestMessage.Headers.Add("X-ARR-ClientCert", certificate.GetRawCertDataString());
var response = await client.SendAsync(requestMessage);
The client certificate is installed in the local computer My
store.
The reason it happens is because I'm not running as Administrator, it works as expected under Administrator privileges. The question is, why?