@@ -257,18 +257,13 @@ internal void AddCertificate(string alias, string certificateEntry, bool overwri
257257 try
258258 {
259259 Pkcs12StoreBuilder storeBuilder = new Pkcs12StoreBuilder ( ) ;
260- Pkcs12Store certs = storeBuilder . Build ( ) ;
260+ Pkcs12Store newEntry = storeBuilder . Build ( ) ;
261261
262262 byte [ ] newCertBytes = removeRootCertificate && ! string . IsNullOrEmpty ( pfxPassword ) ?
263263 RemoveRootCertificate ( Convert . FromBase64String ( certificateEntry ) , pfxPassword ) :
264264 Convert . FromBase64String ( certificateEntry ) ;
265265
266- Pkcs12Store newEntry = storeBuilder . Build ( ) ;
267-
268- X509Certificate2 cert = new X509Certificate2 ( newCertBytes , pfxPassword , X509KeyStorageFlags . Exportable | X509KeyStorageFlags . EphemeralKeySet ) ;
269- byte [ ] binaryCert = cert . Export ( X509ContentType . Pkcs12 , pfxPassword ) ;
270-
271- using ( MemoryStream ms = new MemoryStream ( string . IsNullOrEmpty ( pfxPassword ) ? binaryCert : newCertBytes ) )
266+ using ( MemoryStream ms = new MemoryStream ( newCertBytes ) )
272267 {
273268 newEntry . Load ( ms , string . IsNullOrEmpty ( pfxPassword ) ? new char [ 0 ] : pfxPassword . ToCharArray ( ) ) ;
274269 }
@@ -295,7 +290,8 @@ internal void AddCertificate(string alias, string certificateEntry, bool overwri
295290
296291 if ( string . IsNullOrEmpty ( checkAliasExists ) )
297292 {
298- Org . BouncyCastle . X509 . X509Certificate bcCert = DotNetUtilities . FromX509Certificate ( cert ) ;
293+ //Org.BouncyCastle.X509.X509Certificate bcCert = DotNetUtilities.FromX509Certificate(cert);
294+ Org . BouncyCastle . X509 . X509Certificate bcCert = new Org . BouncyCastle . X509 . X509Certificate ( newCertBytes ) ;
299295 X509CertificateEntry bcEntry = new X509CertificateEntry ( bcCert ) ;
300296 if ( CertificateStore . ContainsAlias ( alias ) )
301297 {
0 commit comments