Fixed an issue with loading certificate bundles on Windows

This commit is contained in:
Kenneth Skovhede
2026-03-19 12:25:33 +01:00
committed by Carl Johnsen
parent 04d5e109eb
commit 287abcdc5e
@@ -106,7 +106,10 @@ public static class CertificateGenerator
// Use a temporary password to avoid unprotected key material in memory
var tempPassword = CertificateStorageHelper.GeneratePfxPassword();
var export = certificate.Export(X509ContentType.Pfx, tempPassword);
var certWithKey = X509CertificateLoader.LoadPkcs12(export, tempPassword);
var certWithKey = X509CertificateLoader.LoadPkcs12(
export,
tempPassword,
X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
CryptographicOperations.ZeroMemory(export);
// Create a new ECDsa instance with the same key parameters for the return value
@@ -224,7 +227,10 @@ public static class CertificateGenerator
// Use a temporary password to avoid unprotected key material in memory
var tempPassword = CertificateStorageHelper.GeneratePfxPassword();
var export = certWithKey.Export(X509ContentType.Pfx, tempPassword);
var finalCert = X509CertificateLoader.LoadPkcs12(export, tempPassword);
var finalCert = X509CertificateLoader.LoadPkcs12(
export,
tempPassword,
X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
CryptographicOperations.ZeroMemory(export);
// Create a new ECDsa instance with the same key parameters