Tôi đang cố gắng sử dụng chứng chỉ tự ký (C#):"Đã xảy ra lỗi nội bộ". khi tải tập tin PFX với X509Certificate2
X509Certificate2 cert = new X509Certificate2(
Server.MapPath("~/App_Data/myhost.pfx"), "pass");
trên một máy chủ lưu trữ web chia sẻ và tôi đã nhận một lỗi:
System.Security.Cryptography.CryptographicException: An internal error occurred.
stack trace đầu với
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
Trên máy tính của tôi, nó tải ok. Lý do tôi tải * .pfx không phải là tệp * .cer vì tôi cần có khóa truy cập riêng (tệp cer tải Ok). tôi đã PFX trên mochine dev của tôi như thế:
makecert -r -n "CN=myhost.com, [email protected]" -sky exchange -b 01/01/2009
-pe -sv myhost.pvk myhost.cer
<b>pvk2pfx</b> -pvk myhost.pvk -spc myhost.cer -pfx myhost.pfx -po pass</code>
Tôi đang sử dụng phiên bản v5.131.3790.0 của makecert
Có lẽ bài viết này có thể trợ giúp: http://www.codeproject.com/KB/WCF/wcfcertificates.aspx – Emmanuel
Tôi nhận được thông báo lỗi 'hệ thống không thể tìm thấy tệp được chỉ định'. Câu trả lời của @Randy Levy đã làm việc cho tôi! – Jess