CertificateRawData Property |
Namespace: MailBee.Security
This sample selects the first certificate from the system store called "MY" ("Personal" tab of Certificates dialog in Internet Explorer) and saves the certificate raw data into the specified file to disk.
Note |
---|
To save the certificate to disk, this sample uses standard binary writer for demonstration purposes only. The developer can call the SaveToFile(String, CertFileType, String) method to save the certificate to disk. |
// To use the code below, import MailBee namespace at the top of your code. using System.IO; using MailBee.Security; // The actual code (put it into a method of your class). CertificateStore store = new CertificateStore(CertificateStore.Personal, CertStoreType.System, null); CertificateCollection collection = store.GetAllCertificates(); if (collection.Count > 0) { Certificate cert = collection[0]; using (BinaryWriter bw = new BinaryWriter(File.Open(@"C:\Temp\newcert.cer", FileMode.Create))) { bw.Write(cert.RawData); bw.Flush(); } }