-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
area-System.Securityneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsiderationregression-from-last-release
Milestone
Description
Description
When going from .Net 8 to .Net 9 and setting up a Named HttpClient for DI with a handler the certificate is never sent. Verified the certificate is never sent by using WireShark to intercept the network communications.
Reproduction Steps
.Net 8
services.AddHttpClient("NamedClient",
client => { client.BaseAddress = new Uri("serverUrl"); })
.ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual
};
var certs = new X509Certificate2(
configuration.GetValue<string>("CertPath")!,
configuration.GetValue<string>("CertPassword")!, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);
handler.ClientCertificates.Add(certs);
return handler;
}
)
.Net 9, Also tired with the same Obsolete code using new X509Certificate2 with the same result.
services.AddHttpClient("NamedClient",
client => { client.BaseAddress = new Uri("serverUrl"); })
.ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual
};
var certs =X509CertificateLoader.LoadPkcs12FromFile(
configuration.GetValue<string>("CertPath")!,
configuration.GetValue<string>("CertPassword")!, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);
handler.ClientCertificates.Add(certs);
return handler;
}
)
Expected behavior
Certificate is sent during handshake.
Actual behavior
No certificate sent
Regression?
Worked as Expected .Net 8
Known Workarounds
No response
Configuration
.Net 9 RC2
Windows 11 x64
Other information
No response
Daniel-Svensson
Metadata
Metadata
Assignees
Labels
area-System.Securityneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsiderationregression-from-last-release