ryder96_
ryder96_
CC#
Created by ryder96_ on 1/26/2023 in #help
How to use certificate on HttpClient
I'm trying to add a certificate to my http client but on request it gives the exception RemoteCertificateNameMismatch and i do not understand why it fails i followed the instructions on msdn doc. Code where i create my client
c#
builder.Services.AddHttpClient("sslClient")
.ConfigurePrimaryHttpMessageHandler(() =>
{

var handler = new HttpClientHandler();
var certificate = new X509Certificate2("Certificates/certificate.pfx", "password");
handler.ClientCertificates.Add(certificate);
return handler;
});
c#
builder.Services.AddHttpClient("sslClient")
.ConfigurePrimaryHttpMessageHandler(() =>
{

var handler = new HttpClientHandler();
var certificate = new X509Certificate2("Certificates/certificate.pfx", "password");
handler.ClientCertificates.Add(certificate);
return handler;
});
Code where i create it and I do the get request
c#
var httpClient = _httpClientFactory.CreateClient("sslClient");
try
{
var response = await httpClient.GetAsync(endpoint);
} catch ...
c#
var httpClient = _httpClientFactory.CreateClient("sslClient");
try
{
var response = await httpClient.GetAsync(endpoint);
} catch ...
1 replies
CC#
Created by ryder96_ on 11/24/2022 in #help
❔ Help with DI, i have different connection strings but same behavior for query DB
Hi, i want to instance the same query service but with different configuration and i have no idea how to do it easily. The problem is that i have other services that use multiple query services with different configurations.
3 replies