我正在尝试使用命令行将两个证书导入到我的本地机器中。
我有一个要添加到本地计算机的个人存储区的证书,另一个要添加到受信任的根证书颁发机构。
这是添加到个人存储区而不添加到根目录的命令:
certutil -f -importpfx CA.pfx NoRoot
那么要添加到受信任的根证书颁发机构而不是个人存储区呢?有任何标签吗?我没有在命令帮助中找到相关信息"/?"
我正在尝试使用命令行将两个证书导入到我的本地机器中。
我有一个要添加到本地计算机的个人存储区的证书,另一个要添加到受信任的根证书颁发机构。
这是添加到个人存储区而不添加到根目录的命令:
certutil -f -importpfx CA.pfx NoRoot
那么要添加到受信任的根证书颁发机构而不是个人存储区呢?有任何标签吗?我没有在命令帮助中找到相关信息"/?"
请查看 certutil.exe 和 -addstore 选项 的文档。
我尝试过
certutil -addstore "Root" "c:\cacert.cer"
它运行良好(意思是证书落入了本地计算机存储的可信任根目录)。
编辑:
如果PFX文件中有多个证书(密钥+对应的证书和CA证书),那么这个命令对我很有效:
certutil -importpfx c:\somepfx.pfx
编辑2:
要将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
使用PowerShell有一个相当简单的答案。
Import-PfxCertificate -Password $secure_pw -CertStoreLocation Cert:\LocalMachine\Root -FilePath certs.pfx
关键在于创建一个“安全”的密码...
$plaintext_pw = 'PASSWORD';
$secure_pw = ConvertTo-SecureString $plaintext_pw -AsPlainText -Force;
Import-PfxCertificate -Password $secure_pw -CertStoreLocation Cert:\LocalMachine\Root -FilePath certs.pfx;