Skip to content

Commit

Permalink
Actually assign loaded cert when generating pfx (#1609)
Browse files Browse the repository at this point in the history
* Actually assign loaded cert when generating pfx

* Enable tests that would have caught this issue
  • Loading branch information
rmja authored Jan 21, 2025
1 parent f7e7613 commit 73b318b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/KubernetesClient/CertUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/KubernetesClient.Tests/AuthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 73b318b

Please sign in to comment.