Export a Pkcs10CertificationRequest object to a .pem file

92 views Asked by At

I have been testing Bouncy Castle in C#. I have not found a way to export a Pkcs10CertificationRequest object to a .pem file. I have tried with PemWriter objects but I have not succeeded. It can be the code or some idea of ​​how to do it. Can someone help me. Thank you

1

There are 1 answers

1
Peter Dettman On BEST ANSWER

You don't mention what version of BC you are using, but at least in recent versions it is directly supported by PemWriter:

Pkcs10CertificationRequest pkcs10 = ...;
FileStream file = ...;

using (var w = new Org.BouncyCastle.OpenSsl.PemWriter(new StreamWriter(file)))
{
    w.WriteObject(pkcs10);
}