Home > Uncategorized > Decode an SSL Cert from a byte array in C#

Decode an SSL Cert from a byte array in C#


This is more of a useful code snippet than any great revelation, however, if you ever needed to convert a byte array of a X509 cert into a X509 certificate object, then here’s how you do it using BouncyCastle

var certificateBase64 = File.ReadAllText(“cert.txt”);
var certData = Convert.FromBase64String(certificateBase64);
var parser = new X509CertificateParser();
var cert = parser.ReadCertificate(certData);

Really easy!; Here’s the project on GitHub – https://github.com/infiniteloopltd/CertificateDecoder


Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: