I assume that you are on the windows.
How I did this is to install a certificate. Open certificates (from mmc or directly) Open the certificate in question.
On the "Details" tab there is an option "Copy to file". Click on until the export file format appears.
Select Base-64 encoded X.509 (.cer). Save to the desktop.
If you open this file in notepad, it will display a base64 encoded public key between the ---- BEGIN CERTIFICATE ---- and ----- END CERTIFICATE ------
Edit:
I save this base64 string and then convert back to code to get the actual certificate. This is pretty easy.
var base64Cert = // read from Db or somewhere var base64EncodedStr = Encoding.Unicode.GetString(base64Cert); var cert = new X509Certificate2(Convert.FromBase64String(base64EncodedStr), "password", X509KeyStorageFlags.PersistKeySet); if(cert != null) { // use certificate }
Peter Lea
source share