workaround for pem cert on windows (#738)

This commit is contained in:
Boshi Lian
2021-10-26 14:57:10 -07:00
committed by GitHub
parent ae591580b6
commit 7a0248609d

View File

@@ -8,12 +8,13 @@ using Org.BouncyCastle.X509;
#endif #endif
using System; using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Text; using System.Text;
namespace k8s namespace k8s
{ {
public static class CertUtils internal static class CertUtils
{ {
/// <summary> /// <summary>
/// Load pem encoded cert file /// Load pem encoded cert file
@@ -90,7 +91,15 @@ namespace k8s
} }
return X509Certificate2.CreateFromPem(certData, keyData); var cert = X509Certificate2.CreateFromPem(certData, keyData);
// see https://github.com/kubernetes-client/csharp/issues/737
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12));
}
return cert;
#else #else
byte[] keyData = null; byte[] keyData = null;