@@ -36,7 +36,10 @@ public static X509Certificate2Collection LoadPemFileCert(string file)
36
36
//
37
37
foreach ( Org . BouncyCastle . X509 . X509Certificate cert in certs )
38
38
{
39
- certCollection . Add ( new X509Certificate2 ( cert . GetEncoded ( ) ) ) ;
39
+ // This null password is to change the constructor to fix this KB:
40
+ // https://support.microsoft.com/en-us/topic/kb5025823-change-in-how-net-applications-import-x-509-certificates-bf81c936-af2b-446e-9f7a-016f4713b46b
41
+ string nullPassword = null ;
42
+ certCollection . Add ( new X509Certificate2 ( cert . GetEncoded ( ) , nullPassword ) ) ;
40
43
}
41
44
#endif
42
45
}
@@ -96,13 +99,17 @@ public static X509Certificate2 GeneratePfx(KubernetesClientConfiguration config)
96
99
// see https://github.com/kubernetes-client/csharp/issues/737
97
100
if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
98
101
{
102
+ // This null password is to change the constructor to fix this KB:
103
+ // https://support.microsoft.com/en-us/topic/kb5025823-change-in-how-net-applications-import-x-509-certificates-bf81c936-af2b-446e-9f7a-016f4713b46b
104
+ string nullPassword = null ;
105
+
99
106
if ( config . ClientCertificateKeyStoreFlags . HasValue )
100
107
{
101
- cert = new X509Certificate2 ( cert . Export ( X509ContentType . Pkcs12 ) , "" , config . ClientCertificateKeyStoreFlags . Value ) ;
108
+ cert = new X509Certificate2 ( cert . Export ( X509ContentType . Pkcs12 ) , nullPassword , config . ClientCertificateKeyStoreFlags . Value ) ;
102
109
}
103
110
else
104
111
{
105
- cert = new X509Certificate2 ( cert . Export ( X509ContentType . Pkcs12 ) ) ;
112
+ cert = new X509Certificate2 ( cert . Export ( X509ContentType . Pkcs12 ) , nullPassword ) ;
106
113
}
107
114
}
108
115
@@ -172,13 +179,17 @@ public static X509Certificate2 GeneratePfx(KubernetesClientConfiguration config)
172
179
173
180
store . Save ( pkcs , new char [ 0 ] , new SecureRandom ( ) ) ;
174
181
182
+ // This null password is to change the constructor to fix this KB:
183
+ // https://support.microsoft.com/en-us/topic/kb5025823-change-in-how-net-applications-import-x-509-certificates-bf81c936-af2b-446e-9f7a-016f4713b46b
184
+ string nullPassword = null ;
185
+
175
186
if ( config . ClientCertificateKeyStoreFlags . HasValue )
176
187
{
177
- return new X509Certificate2 ( pkcs . ToArray ( ) , "" , config . ClientCertificateKeyStoreFlags . Value ) ;
188
+ return new X509Certificate2 ( pkcs . ToArray ( ) , nullPassword , config . ClientCertificateKeyStoreFlags . Value ) ;
178
189
}
179
190
else
180
191
{
181
- return new X509Certificate2 ( pkcs . ToArray ( ) ) ;
192
+ return new X509Certificate2 ( pkcs . ToArray ( ) , nullPassword ) ;
182
193
}
183
194
#endif
184
195
}
0 commit comments