Skip to content

Commit 7a02486

Browse files
authored
workaround for pem cert on windows (#738)
1 parent ae59158 commit 7a02486

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/KubernetesClient/CertUtils.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
#endif
99
using System;
1010
using System.IO;
11+
using System.Runtime.InteropServices;
1112
using System.Security.Cryptography.X509Certificates;
1213
using System.Text;
1314

1415
namespace k8s
1516
{
16-
public static class CertUtils
17+
internal static class CertUtils
1718
{
1819
/// <summary>
1920
/// Load pem encoded cert file
@@ -90,7 +91,15 @@ public static X509Certificate2 GeneratePfx(KubernetesClientConfiguration config)
9091
}
9192

9293

93-
return X509Certificate2.CreateFromPem(certData, keyData);
94+
var cert = X509Certificate2.CreateFromPem(certData, keyData);
95+
96+
// see https://github.com/kubernetes-client/csharp/issues/737
97+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
98+
{
99+
cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12));
100+
}
101+
102+
return cert;
94103
#else
95104

96105
byte[] keyData = null;

0 commit comments

Comments
 (0)