title: Exporting a Certificate as BASE-64 encoded .cer
body: <p>I am trying to export a cert without the private key as as BASE-64 encoded file, same as exporting it from windows. When exported from windows I am able to open the .cer file in notepad.</p>
  
  <p>When I try the following and open on notepad I get binary data...I think it is...not readable.</p>
  
  <pre><code>X509Certificate2 cert = new X509Certificate2("c:\\myCert.pfx", "test", X509KeyStorageFlags.Exportable);
  
  File.WriteAllBytes("c:\\testcer.cer", cert.Export(X509ContentType.Cert));
  </code></pre>
  
  <p>I tried removing the 'X509KeyStorageFlags.Exportable" but that doesn't work. Am I missing something?</p>
  
  <p>Edit - I tried</p>
  
  <pre><code>File.WriteAllText("c:\\testcer.cer",Convert.ToBase64String(cert.Export(X509ContentType.Cert)))
  </code></pre>
  
  <p>and that seems to work, however, missing the "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----"</p>