Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get string from X509 Cert pfx file

I want to get the x509 certificate as a string (certString) so that I can use it like

var cert = new X509Certificate2(Convert.FromBase64String(certString));

to generate a CertObject in Code.

I have tried around with certUtil but I dont know exactly which string I need.

Which string do I need to extract from the pfx data to be able to generate the X509 Certificate object in Code?

like image 714
EngelbertCoder Avatar asked Dec 14 '22 07:12

EngelbertCoder


1 Answers

Here is the full code sample:

var cert = new X509Certificate2(@"c:\myCert.pfx", "password");
var certBytes = cert.RawData;
var certString = Convert.ToBase64String(certBytes);
like image 54
Samuel S. Avatar answered Dec 28 '22 03:12

Samuel S.