From 48d16b65a5f0ee15f9c73514b13ccdb864c8121f Mon Sep 17 00:00:00 2001 From: jvmdc <109624469+jvmdc@users.noreply.github.com> Date: Fri, 27 Dec 2024 10:09:22 +0100 Subject: [PATCH] fix: Load PKCS#12 correctly for mTLS on Windows in .NET 9 (#1320) --- .../Builders/MTlsEndpointAuthenticationProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Testcontainers/Builders/MTlsEndpointAuthenticationProvider.cs b/src/Testcontainers/Builders/MTlsEndpointAuthenticationProvider.cs index fddec6aa8..7beb6d400 100644 --- a/src/Testcontainers/Builders/MTlsEndpointAuthenticationProvider.cs +++ b/src/Testcontainers/Builders/MTlsEndpointAuthenticationProvider.cs @@ -56,7 +56,7 @@ protected override X509Certificate2 GetClientCertificate() return Polyfills.X509Certificate2.CreateFromPemFile(clientCertificateFilePath, clientCertificateKeyFilePath); #elif NET9_0_OR_GREATER var certificate = X509Certificate2.CreateFromPemFile(clientCertificateFilePath, clientCertificateKeyFilePath); - return OperatingSystem.IsWindows() ? X509CertificateLoader.LoadCertificate(certificate.Export(X509ContentType.Pfx)) : certificate; + return OperatingSystem.IsWindows() ? X509CertificateLoader.LoadPkcs12(certificate.Export(X509ContentType.Pfx), null) : certificate; #elif NET6_0_OR_GREATER var certificate = X509Certificate2.CreateFromPemFile(clientCertificateFilePath, clientCertificateKeyFilePath); return OperatingSystem.IsWindows() ? new X509Certificate2(certificate.Export(X509ContentType.Pfx)) : certificate;