Windows 通过命令行安装根证书 您所在的位置:网站首页 raz单词重复率 Windows 通过命令行安装根证书

Windows 通过命令行安装根证书

2023-11-06 22:31| 来源: 网络整理| 查看: 265

证书链的原理:

根证书自签名,而其他证书的公钥使用根证书的公钥验证,验证通过的则子证书有效,子证书则可以发行下一个分支。

有的时候我们需要在用户机器上将自制的 CA 证书安装到“受信任的根证书颁发机构”下,这样就能使用该 CA 颁发自签名的证书了,以便后续完成一些安全相关的操作。

工具

在命令行安装证书需要用到证书管理器 certmgr.exe,这个二进制可执行文件在 Win10 中 大概 这个路径下,C:\Program Files (x86)\Windows Kits\8.1\bin\x86\certmgr.exe,建议把这个二进制打在程序的发布包中,或者让程序从网络上拉取到本地。

certmgr.exe

可以通过该工具实现证书的管理操作:

D:\>certmgr.exe /? Usage: CertMgr [options][-s [-r ][SourceStoreName] [-s [-r ][DestinationStoreName] Options: -add Add certificates/CRLs/CTLs to a storeFile or a system store -del Delete certificates/CRLs/CTLs from a storeFile or a system store -put Put an encoded certificate/CRL/CTL from a storeFile or a system store to a file. The file will be saved in X.509 format. -7 can be used to save the file in PKCS #7 format -s Indicate the store is a system store -r The system store location Default to 'currentUser' -c Certificates in the store -crl Certificates revocation lists(CRLs) in the store -ctl Certificates trust lists(CTLs) in the store -v Verbose display of the certificates/CRLs/CTLs -all All certificates/CRLs/CTLs in the store -n Common name of the certificate -sha1 The sha1 hash of the certificate/CRLs/CTLs -7 Save the destination store in PKCS #7 format -e Certificate/CRL/CTL encoding type. Default to X509_ASN_ENCODING -f CertStore open flags. Meaningful only if -y is set -y CertStore provider name

我们的目标是将 CA 证书导入到“受信任的根证书颁发机构”下,可以通过如下命令参数实现:certmgr.exe /c /add ca.crt /s root

导入之前可以通过 certmgr.exe /all /s root 来查询是否已经导入过。

结论certmgr.exe 需要自己分发到确定的路径下再调用作为用户不要轻易安装来历不明的证书


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有