C#.NET ASP.NET IIS 加载.pfx私钥证书时报错“出现了内部错误。”()

C#.NET ASP.NET IIS 加载.pfx私钥证书时报错“出现了内部错误。”

原始代码报错:

X509Certificate2 x509cer = new X509Certificate2(rawData, m.cert_pwd);

解决方法,加上enum:

X509Certificate2 x509cer = new X509Certificate2(rawData, m.cert_pwd,
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);

X509Certificate2

————————

C#.NET ASP.NET IIS 加载.pfx私钥证书时报错“出现了内部错误。”

原始代码报错:

X509Certificate2 x509cer = new X509Certificate2(rawData, m.cert_pwd);

解决方法,加上enum:

X509Certificate2 x509cer = new X509Certificate2(rawData, m.cert_pwd,
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);

X509Certificate2