Actually assign loaded cert when generating pfx (#1609)

* Actually assign loaded cert when generating pfx

* Enable tests that would have caught this issue
This commit is contained in:
Rasmus Melchior Jacobsen
2025-01-21 05:06:35 +01:00
committed by GitHub
parent f7e7613d09
commit 73b318ba34
2 changed files with 5 additions and 5 deletions

View File

@@ -81,7 +81,7 @@ namespace k8s
if (config.ClientCertificateKeyStoreFlags.HasValue) if (config.ClientCertificateKeyStoreFlags.HasValue)
{ {
#if NET9_0_OR_GREATER #if NET9_0_OR_GREATER
X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pkcs12), nullPassword, config.ClientCertificateKeyStoreFlags.Value); cert = X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pkcs12), nullPassword, config.ClientCertificateKeyStoreFlags.Value);
#else #else
cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12), nullPassword, config.ClientCertificateKeyStoreFlags.Value); cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12), nullPassword, config.ClientCertificateKeyStoreFlags.Value);
#endif #endif
@@ -90,7 +90,7 @@ namespace k8s
else else
{ {
#if NET9_0_OR_GREATER #if NET9_0_OR_GREATER
X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pkcs12), nullPassword); cert = X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pkcs12), nullPassword);
#else #else
cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12), nullPassword); cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12), nullPassword);
#endif #endif

View File

@@ -167,8 +167,8 @@ namespace k8s.Tests
} }
} }
// this test doesn't work on OSX and is inconsistent on windows // this test doesn't work on OSX
[OperatingSystemDependentFact(Exclude = OperatingSystems.OSX | OperatingSystems.Windows)] [OperatingSystemDependentFact(Exclude = OperatingSystems.OSX)]
public void Cert() public void Cert()
{ {
var serverCertificateData = File.ReadAllText("assets/apiserver-pfx-data.txt"); var serverCertificateData = File.ReadAllText("assets/apiserver-pfx-data.txt");
@@ -273,7 +273,7 @@ namespace k8s.Tests
} }
} }
[OperatingSystemDependentFact(Exclude = OperatingSystems.OSX | OperatingSystems.Windows)] [OperatingSystemDependentFact(Exclude = OperatingSystems.OSX)]
public void ExternalCertificate() public void ExternalCertificate()
{ {
const string name = "testing_irrelevant"; const string name = "testing_irrelevant";