将证书导入到受信任的根目录,但不导入到个人目录[命令行]



我正在尝试使用命令行将两个证书导入到我的本地计算机。

我有一个证书要添加到本地计算机的个人存储中,还有一个要添加到受信任的根证书颁发机构中。

这是一个命令,必须在个人存储,而不是在根目录下添加:

certutil -f -importpfx CA.pfx NoRoot

并添加在可信根而不是个人?有标签吗?我没有找到命令帮助"/?"

查看certutil.exe和-addstore选项的文档

I tried

certutil -addstore "Root" "c:cacert.cer"

,它工作得很好(意味着证书降落在LocalMachine存储的受信任根)。

编辑:

如果在一个pfx文件中有多个证书(密钥+相应的证书和CA证书),那么这个命令对我来说工作得很好:

certutil -importpfx c:somepfx.pfx

EDIT2:

要将CA证书导入到中间证书颁发机构存储,请运行以下命令

certutil -addstore "CA" "c:intermediate_cacert.cer"

下面的命令将帮助您将证书添加到根存储-

certutil -enterprise -f -v -AddStore "Root" <Cert File path>

打印根存储的内容:

certutil -store Root

输出内容到文件:

certutil -store Root > root_content.txt

将证书添加到根存储:

certutil -addstore -enterprise Root file.cer

如果在一个pfx文件中有多个证书(密钥+相应的证书和CA证书),那么这个命令对我来说工作得很好:

certutil -importpfx c:somepfx.pfx这是有效的,但仍然需要手动输入私钥密码。包含-p和"password"会导致错误XP上certutil参数太多

使用powershell有一个相当简单的答案。

Import-PfxCertificate -Password $secure_pw  -CertStoreLocation Cert:LocalMachineRoot -FilePath certs.pfx

诀窍是制作一个"安全的"密码…

$plaintext_pw = 'PASSWORD';
$secure_pw = ConvertTo-SecureString $plaintext_pw -AsPlainText -Force; 
Import-PfxCertificate -Password $secure_pw  -CertStoreLocation Cert:LocalMachineRoot -FilePath certs.pfx;

最新更新