How to Encode a Certificate

22 באפריל 2013

tags: ,
no comments

It is common to upload / transfer certificates as base64 strings.
A common example is Azure Management API Add Service Certificate.

To encode a certificate all you have to do is simply encode the certificate file.

var encodedClientCert = Convert.ToBase64String(File.ReadAllBytes("Client.Cer"));

To create a certificate out of base64 string is as easy:

string str = "base64string representing a certificate";
string psw = "password for certificates with a private key";
var cert = new X509Certificate2(Convert.FromBase64String(str), psw);

Hope this helps

Manu

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*