"An internal error occurred." when loading pfx file with X509Certificate2
Posted
by tmp3128
on Stack Overflow
See other posts from Stack Overflow
or by tmp3128
Published on 2009-08-28T06:01:37Z
Indexed on
2010/05/22
12:00 UTC
Read the original article
Hit count: 1752
I'm trying use self-signed certificate (c#):
X509Certificate2 cert = new X509Certificate2(Server.MapPath("~/App_Data/myhost.pfx"), "pass");
on a shared web hosting server and I got an error:
System.Security.Cryptography.CryptographicException: An internal error occurred.
stack trace ends with
System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) +33
System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& 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
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:
makecert -r -n "CN=myhost.com, [email protected]" -sky exchange -b 01/01/2009 -pe -sv myhost.pvk myhost.cer
pvk2pfx -pvk myhost.pvk -spc myhost.cer -pfx myhost.pfx -po pass
Please assist;
PS: makecert is a v5.131.3790.0
© Stack Overflow or respective owner