windows 将证书导入受信任的根但不导入个人 [命令行]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23869177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:35:45  来源:igfitidea点击:

Import Certificate to Trusted Root but not to Personal [Command Line]

windowscertificateroottrustedcertutil

提问by TiagoM

I am trying to import two certificates to my local machine using the command line.

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

I have one certificate to add to the Personal Store of the local machine, and another one to add to the Trusted Root Certification Authorities.

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

Here is the command to had to Personal Store and not to add at root:

这是必须到个人存储而不是在 root 中添加的命令:

certutil -f -importpfx CA.pfx NoRoot

certutil -f -importpfx CA.pfx NoRoot

And to add at Trusted Root and not personal ? Is there any tag ? I didn't found at command help "/?"

并添加到受信任的根而不是个人?有标签吗?我在命令帮助中没有找到“/?”

回答by pepo

Look at the documentation of certutil.exeand -addstore option.

查看certutil.exe-addstore option的文档。

I tried

我试过

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

and it worked well (meaning The certificate landed in Trusted Root of LocalMachine store).

并且它运行良好(意味着证书登陆了 LocalMachine 存储的可信根)。

EDIT:

编辑:

If there are multiple certificates in a pfx file (key + corresponding certificate and a CA certificate) then this command worked well for me:

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

certutil -importpfx c:\somepfx.pfx

EDIT2:

编辑2:

To import CA certificate to Intermediate Certification Authorities store run following command

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

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

回答by Alan Jebakumar

The below 'd help you to add the cert to the Root Store-

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

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

This worked for me perfectly.

这对我来说非常有效。

回答by Sandeep Khantwal

To print the content of Root store:

打印根存储的内容:

certutil -store Root

To output content to a file:

将内容输出到文件:

certutil -store Root > root_content.txt

To add certificate to Root store:

将证书添加到根存储:

certutil -addstore -enterprise Root file.cer

回答by cobus

If there are multiple certificates in a pfx file (key + corresponding certificate and a CA certificate) then this command worked well for me:

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

certutil -importpfx c:\somepfx.pfx this works but still a password is needed to be typed in manually for private key. Including -p and "password" cause error too many arguments for certutil on XP

certutil -importpfx c:\somepfx.pfx 这有效,但仍然需要手动输入密码以获取私钥。包括 -p 和“密码”会导致 XP 上 certutil 的参数过多