title: X509Certificate Constructor Exception
body: <pre><code>//cert is an EF Entity and 
  //    cert.CertificatePKCS12 is a byte[] with the certificate.
  
  var certificate = new X509Certificate(cert.CertificatePKCS12, "SomePassword");
  </code></pre>
  
  <p>When loading a certificate from our database, on our staging server (Windows 2008 R2/IIS7.5) we get this exception:</p>
  
  <pre><code>System.Security.Cryptography.CryptographicException: An internal error occurred.
  
     at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
     at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle&amp; pCertCtx)
     at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
  </code></pre>
  
  <p><strong>NOTE:</strong> This issue does not happen locally (Windows 7/Casini).</p>
  
  <p>Any insight is greatly appreciated.</p>