From 4b14395a24552beb86155685f8b23332fe72f5d8 Mon Sep 17 00:00:00 2001 From: Rasmus Melchior Jacobsen Date: Mon, 20 Jan 2025 22:22:19 +0100 Subject: [PATCH 1/2] Actually assign loaded cert when generating pfx --- src/KubernetesClient/CertUtils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KubernetesClient/CertUtils.cs b/src/KubernetesClient/CertUtils.cs index cb8af5d20..7a398d7e8 100644 --- a/src/KubernetesClient/CertUtils.cs +++ b/src/KubernetesClient/CertUtils.cs @@ -81,7 +81,7 @@ public static X509Certificate2 GeneratePfx(KubernetesClientConfiguration config) if (config.ClientCertificateKeyStoreFlags.HasValue) { #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 cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12), nullPassword, config.ClientCertificateKeyStoreFlags.Value); #endif @@ -90,7 +90,7 @@ public static X509Certificate2 GeneratePfx(KubernetesClientConfiguration config) else { #if NET9_0_OR_GREATER - X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pkcs12), nullPassword); + cert = X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pkcs12), nullPassword); #else cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12), nullPassword); #endif From c239a730578687080ffba7ef997aae85b6e693d2 Mon Sep 17 00:00:00 2001 From: Rasmus Melchior Jacobsen Date: Mon, 20 Jan 2025 23:30:04 +0100 Subject: [PATCH 2/2] Enable tests that would have caught this issue --- tests/KubernetesClient.Tests/AuthTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/KubernetesClient.Tests/AuthTests.cs b/tests/KubernetesClient.Tests/AuthTests.cs index 3e9cf684d..227ccb66c 100644 --- a/tests/KubernetesClient.Tests/AuthTests.cs +++ b/tests/KubernetesClient.Tests/AuthTests.cs @@ -167,8 +167,8 @@ public void BasicAuth() } } - // this test doesn't work on OSX and is inconsistent on windows - [OperatingSystemDependentFact(Exclude = OperatingSystems.OSX | OperatingSystems.Windows)] + // this test doesn't work on OSX + [OperatingSystemDependentFact(Exclude = OperatingSystems.OSX)] public void Cert() { var serverCertificateData = File.ReadAllText("assets/apiserver-pfx-data.txt"); @@ -273,7 +273,7 @@ public void Cert() } } - [OperatingSystemDependentFact(Exclude = OperatingSystems.OSX | OperatingSystems.Windows)] + [OperatingSystemDependentFact(Exclude = OperatingSystems.OSX)] public void ExternalCertificate() { const string name = "testing_irrelevant";