Discuss this help topic in SecureBlackbox Forum

Save certificate request

Once you've generated your certificate request you would normally like to save it to a file. As a matter of fact, in most cases we deal with two files: one containing the request itself (which is going to be sent to the CA), and another one containing the private key.

First, create a file stream object for the request file and save the public request using the TElCertificateRequest.SaveToStream() method:


FileStream reqf = new FileStream("request.req", FileMode.Create);
try
{
  req.SaveToStream(reqf);
}
finally
{
  reqf.Close();
}
Next, create a different file for the private key and use SaveKeyToStream() to save the key:

FileStream keyf = new FileStream("request.key", FileMode.Create);
try
{
  req.SaveKeyToStream(keyf);
}
finally
{
  keyf.Close();
}
That's it, now you can send request.req to your CA and wait for your brand new certificate. Keep request.key in a safe place, you will need it for signing and decrypting data.

Alternatively to the above SaveToStream() and SaveKeyToStream() methods you can use format-specific methods: SaveToStreamPEM(), SaveKeyToStreamPEM(), SaveKeyToStreamPVK(). They do exactly the same as the methods described above with the only difference in the type of the resulting file format (PEM or PVK).

How To articles about certificate requests

Discuss this help topic in SecureBlackbox Forum