Dro*_*mer 16 c# certificate visual-studio x509
我的学校网页有自我证书(你必须手动安装),我想创建一个程序,在我点击一个按钮后,会安装一个certificate.cer(从visual studio资源)到本地用户 - "Trusted root certificate authority".你有吗?知道如何在Visual C#中编码吗?
akt*_*ton 49
要以编程方式将证书添加到当前用户的受信任根存储,请使用X509Store和X509Certificate2类.例如:
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();
Run Code Online (Sandbox Code Playgroud)
另请参阅" 如何使用c#以编程方式将证书安装到本地计算机存储中? ".
另一个选项是证书管理器命令行(certmgr.exe)工具,具体为:
certmgr /add cert.cer /s Root
Run Code Online (Sandbox Code Playgroud)
其中"cert.cer"是您的证书.这会将其导入到当前用户的受信任根存储中.但是,certmgr.exe是Visual Studio和Windows SDK的一部分,可能无法自由分发.
| 归档时间: |
|
| 查看次数: |
41949 次 |
| 最近记录: |