【发布时间】:2017-12-30 06:01:22
【问题描述】:
我需要从磁盘位置读取 p12 文件,在我的本地环境中一切正常,但是当我将站点发布到 windows server 2008 时,我收到以下错误:
System.Security.Cryptography.CryptographicException:内部错误 发生了。
在 System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 小时)在 System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(字符串 fileName, IntPtr 密码, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle & pCertCtx) 在 System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(字符串 文件名,对象密码,X509KeyStorageFlags keyStorageFlags)在 System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(字符串 文件名、字符串密码、X509KeyStorageFlags keyStorageFlags)
我的代码是:
var certP12 = new X509Certificate2(
@"C:\temp\file.p12",
"123456",
X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
我已经为包含 p12 文件的文件夹设置了完全权限。
有人可以帮忙吗?
【问题讨论】:
-
九 对不起,我更改了路径以显示代码更简单,我会更新这个,但这不是问题,谢谢
-
您是否尝试过以管理员权限运行应用程序?
-
这在一个网站上发布在 IIS 上,使用 AppPoolIdentity 运行,其他具有相同身份的应用程序工作正常
标签: c# ssl-certificate windows-server-2008