title: Can I Convert X509 Certificate to string/byte to use later?
body: <p>I have a situation where I need X509 certificate and have easy way to pass strings to it. Can I somehow convert the certificate to string and back to certificate?</p>
  
  <p>I tried the following and everything works good except the certificate thumbprint is changed.</p>
  
  <pre><code>var originalCert = new X509Certificate2("C:\\cert.pfx", "password");
  var byteCert = originalCert.GetRawCertData();
  var stringCert = Encoding.Unicode.GetString(byteCert);
  var convertedBytes = Encoding.Unicode.GetBytes(stringCert);
  var convertedCert = new X509Certificate2(convertedBytes);
  
  var equalThumbprints = originalCert.Thumbprint == convertedCert.Thumbprint; //this returns false
  </code></pre>
  
  <p>How can I get exact same certificate in this case?</p>
  
  <p>shouldn't the certificate thumbprint be unique and be generated by certificate authority?</p>