通过命令行在 Windows 7 上导入 .PEM 证书

V.G*_*.G. 33 windows windows-7 certificate command-line

我需要在大量新安装的 Windows 7 Enterprise 机器上导入PEM 证书

通常,我会通过 MMC 来完成?证书(本地计算机)管理单元?受信任的根证书 ? 导入,但我需要加快速度。因此,我只想使用命令提示符。

使用certmgr.exe(不是certmgr.msc!),我会输入:

certmgr.exe -add -c C:\certificate.pem -s -r localMachine root
Run Code Online (Sandbox Code Playgroud)

问题是certmgr.exe在 Windows 7 中不存在。那么如何从命令行添加证书?

gar*_*Red 61

您需要certutil.exe改用:

certutil –addstore -enterprise –f "Root" <pathtocertificatefile>
Run Code Online (Sandbox Code Playgroud)

将证书添加到受信任的根证书颁发机构存储。

如果要添加中间证书颁发机构,请替换RootCA和 添加到您的个人存储中,将其更改为My.

以上所有将证书添加到本地计算机存储。要添加到用户存储-enterprise,请从命令行中删除:

certutil –addstore –f "Root" <pathtocertificatefile>
Run Code Online (Sandbox Code Playgroud)

-f在命令只是强迫在该证书已经安装的情况下的覆盖。

  • *要添加到用户存储,请删除 -enterprise*:删除“-enterprise”似乎会尝试将其添加到计算机存储,并且需要“-user”来选择用户存储。也许 Windows 10 中的情况发生了变化。这是相关的文档:*使用 `-user` 访问用户存储而不是计算机存储。*--https://docs.microsoft.com/en-us/windows-server/管理/windows-命令/certutil (2认同)