title: "An internal error occurred." when loading pfx file with X509Certificate2
body: <p>I'm trying use self-signed certificate (c#):</p>
  
  <pre><code>X509Certificate2 cert = new X509Certificate2(
      Server.MapPath("~/App_Data/myhost.pfx"), "pass");
  </code></pre>
  
  <p>on a shared web hosting server and I got an error:</p>
  
  <pre><code>System.Security.Cryptography.CryptographicException: An internal error occurred.
  </code></pre>
  
  <p>stack trace ends with</p>
  
  <pre><code>System.Security.Cryptography.CryptographicException.
      ThrowCryptogaphicException(Int32 hr) +33
  System.Security.Cryptography.X509Certificates.X509Utils.
      _LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, 
          Boolean persistKeySet, SafeCertContextHandle&amp; pCertCtx) +0
  System.Security.Cryptography.X509Certificates.X509Certificate.
      LoadCertificateFromFile(String fileName, Object password, 
          X509KeyStorageFlags keyStorageFlags) +237
  System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(
      String fileName, String password) +131
  </code></pre>
  
  <p>On my dev machine it loads ok.
  The reason I load *.pfx not a *.cer file because I need a private key access (cer file loads Ok).
  I made pfx on my dev mochine like that:</p>
  
  <pre><code>makecert -r -n "CN=myhost.com, E=admin@myhost.com" -sky exchange -b 01/01/2009
      -pe -sv myhost.pvk myhost.cer
  &lt;b&gt;pvk2pfx&lt;/b&gt; -pvk myhost.pvk -spc myhost.cer -pfx myhost.pfx -po pass&lt;/code&gt;
  </code></pre>
  
  <p>I am using version v5.131.3790.0 of makecert</p>