title: How to get the base 64 encoded value of a certificate with private key?
body: <p>Follow up to a <a href="https://stackoverflow.com/a/8863478/304832">previous question</a>, I have some code that needs to get an X509 certificate with a private key. As noted in the answers, in production this will happen using X509Store.</p>
  
  <p>What is the best way to unit test this? I want to develop and test with different certificates than will be in production, so I could create a CertificateRepository interface to provide different implementations. </p>
  
  <p>For the test / dev implementation, it would be nice to just use a base64 encoded string of the certificate, and create a cert instance that way, with a dummy password and dedicated test / dev cert. However so far I have been unable to figure out how to encode a certificate with private key as a base64 string. Each time I try to export the cert from MMC as base-64, it encodes the public key only. </p>