Skip to content

Commit 48d16b6

Browse files
authored
fix: Load PKCS#12 correctly for mTLS on Windows in .NET 9 (#1320)
1 parent 1543575 commit 48d16b6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Testcontainers/Builders/MTlsEndpointAuthenticationProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected override X509Certificate2 GetClientCertificate()
5656
return Polyfills.X509Certificate2.CreateFromPemFile(clientCertificateFilePath, clientCertificateKeyFilePath);
5757
#elif NET9_0_OR_GREATER
5858
var certificate = X509Certificate2.CreateFromPemFile(clientCertificateFilePath, clientCertificateKeyFilePath);
59-
return OperatingSystem.IsWindows() ? X509CertificateLoader.LoadCertificate(certificate.Export(X509ContentType.Pfx)) : certificate;
59+
return OperatingSystem.IsWindows() ? X509CertificateLoader.LoadPkcs12(certificate.Export(X509ContentType.Pfx), null) : certificate;
6060
#elif NET6_0_OR_GREATER
6161
var certificate = X509Certificate2.CreateFromPemFile(clientCertificateFilePath, clientCertificateKeyFilePath);
6262
return OperatingSystem.IsWindows() ? new X509Certificate2(certificate.Export(X509ContentType.Pfx)) : certificate;

0 commit comments

Comments
 (0)