How to Decode a Csr File?

How to Decode a Csr File?

I ran accross a CSR file (Certificate Signing Request) and I need to extract some information from it.

There's a way to decode it using .NET Framework?

1

4 Answers

It's not .NET, but for interactive use, try the OpenSSL utilities. Specifically:

openssl req -text -in request.csr
certutil -dump file.csr

Will also dump all relevant information. Builtin in Windows by default.

2

Decoding a CSR is easy if you employ the OpenSSL.NET library:

// Load the CSR file
var csr = new X509Request(BIO.File("C:/temp/test.csr", "r"));
OR
var csr = new X509Request(@"-----BEGIN CERTIFICATE REQUEST-----...");

// Read CSR file properties
Console.WriteLine(csr.PublicKey.GetRSA().PublicKeyAsPEM);
Console.WriteLine(csr.Subject.SerialNumber);
Console.WriteLine(csr.Subject.Organization);
.
.
.

X509Request type has properties to get everything out of your CSR file text.

Try Liping Dai's website. His LCLib has ASN1 Parser which wrote in C#. It can decode CSR. Work for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.