C
C#10mo ago
Elykx

❔ How to implement integration test asp.net with .net 7 using client certificates ?

When i try to create an httpclient custom in a WebApplicationFactory, the test server is not running
builder.ConfigureTestServices(services =>
{
services
.AddHttpClient("client-with-certificate", client =>
{
client.BaseAddress = new Uri("https://localhost");
})
.ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler();
handler.ClientCertificates.Add(clientCertificate);
return handler;
});
});
builder.ConfigureTestServices(services =>
{
services
.AddHttpClient("client-with-certificate", client =>
{
client.BaseAddress = new Uri("https://localhost");
})
.ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler();
handler.ClientCertificates.Add(clientCertificate);
return handler;
});
});
1 Reply
Accord
Accord10mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.