我正在使用此代码从PFX文件导入证书:
string certPath = @"C:\a\something.eu.pfx";
string certPass = "password";
// Create a collection object and populate it using the PFX file
X509Certificate2 certifikat = new X509Certificate2();
certifikat.Import(certPath, certPass, X509KeyStorageFlags.PersistKeySet);
X509Store store = new X509Store();
store.Open(OpenFlags.MaxAllowed);
store.Add(certifikat);
store.Close();
执行时没有错误,但证书不会出现在“虚拟主机”商店中。如何在该商店中导入它?
答案 0 :(得分:1)
使用X509Store
构造函数,您可以指定要打开的商店。您将需要本地计算机的“Web Hosting”存储(内部名称:“WebHosting”),因此构建类如下所示:
var store = new X509Store("WebHosting", StoreLocation.LocalMachine);