views:

771

answers:

1

Hi im trying to use .Net and c# to export a certificate from the cert store into a PFX file. I'm trying to use the X509certificate2.export method wiht the X509ContentType.Pfx flag set, but am unsure how to handle the returned byte array and output it correctly to file.

Any help appreciated.

Thanks Mark

A: 

Judging by the date, you may have already figured this out, but all you have to do is write the returned byte array directly to a file:

byte[] certData = cert.Export(X509ContentType.Pfx, "MyPassword");
File.WriteAllBytes(@"C:\MyCert.pfx", certData);
Aaronaught