我的学校网页具有可信任的证书(必须手动安装),我想创建一个程序,该程序将在我单击按钮后(从Visual Studio资源中)向本地用户-“受信任的根证书颁发机构”安装一个certificate.cer。您知道如何在Visual C#中对其进行编码吗?
string file; // Contains name of certificate file
X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
store.Add(new X509Certificate2(X509Certificate2.CreateFromCertFile(file)));
store.Close();
另请参阅“ How can I install a certificate into the local machine store programmatically using c#?”。另一个选项是Certificate Manager command line (certmgr.exe)工具,具体是:
certmgr /add cert.cer /s Root
其中“ cert.cer”是您的证书。这会将其导入到当前用户的受信任的根存储中。但是,certmgr.exe是Visual Studio和Windows SDK的一部分,可能不能自由分发。
Sujay M