windows 证书管理 certutil
可使用 certutil 执行一些证书管理任务。
要查看特定任务的语法,请单击任务:
certutil-verify [-f] [-enterprise] [-user] [-gmt] [-seconds] [-silent] [-split] [-v] CertFile [CACertFile]
参数- -verify
- 验证该证书链。
- -f
- Overwrites existing files or keys.
- -enterprise
- 使用本地计算机企业注册表证书存储。
- -user
- Uses the HKEY_CURRENT_USER keys or certificate store.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -silent
- 使用无声标志获得 CryptContext。
- -split
- Splits the embedded Abstract Syntax Notation One (ASN.1) elements, and saves them to files.
- -v
- Specifies verbose output.
- CertFile
- 指定该证书。
- CACertFile
- 指定包含用于验证数字签名的公钥的 CA 签名证书。
- -?
- Displays a list of certutil commands.
- CertFile 和 CACertFile 都必须包含单一证书,而不是 PKCS #7 证书链。
- 该命令行选项还验证 CertFile 证书是否处于吊销状态。如果 CertFile 不包含有关如何检查吊销的信息,或必要的 URL 或 CRL 不可用,则出现一个错误。
- 如果没有指定 CACertFile,则通过使用安装在该计算机上的证书构造 CertFile 的证书链,验证和检查该链中所有证书,以便检查它们是否被吊销。
certutil-isvalid [-gmt] [-seconds] [-v] [-config CAMachineName\CAName] {SerialNumber | CertHash}
参数- -isvalid
- 确定该证书是否有效。
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -v
- Specifies verbose output.
- -configCAMachineName\CAName
- processes the operation by using the CA specified in the configuration string (that is, CAMachineName\CAName).
- SerialNumber
- 指定该证书的序列号。
- CertHash
- 指定该证书的证书哈希。
- -?
- Displays a list of certutil commands.
- You must specify the CAComputerName or CAName in -config CAComputerName\CAName. Otherwise, the Select Certificate Authority dialog box appears and displays a list of all CAs that are available.
- If you use -config - instead of -config CAComputerName\CAName, the operation is processed using the default CA.
- SerialNumber 必须是偶数的十六进制数字。单独的一个零 (0) 可以置于一个奇数值的首位。不允许以 0x 开头。
certutil-installcert [-f] [-gmt] [-seconds] [-v] [-config CAMachineName\CAName] [CACertFile]
参数- -installcert
- 安装 CA 证书。
- -f
- Overwrites existing files or keys.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -v
- Specifies verbose output.
- -configCAMachineName\CAName
- processes the operation by using the CA specified in the configuration string (that is, CAMachineName\CAName).
- CACertFile
- 指定包含用于验证数字签名的公钥的 CA 签名证书。
- -?
- Displays a list of certutil commands.
- You must specify the CAComputerName or CAName in -config CAComputerName\CAName. Otherwise, the Select Certificate Authority dialog box appears and displays a list of all CAs that are available.
- If you use -config - instead of -config CAComputerName\CAName, the operation is processed using the default CA.
- PKCS #7 证书链是 CACertFile 的首选内容。但如果将用于形成该链的所有证书已安装在本地计算机上,则接受 X.509v3 证书。
- 该命令还为已产生申请、但尚未收到和安装其 CA 证书的下级 CA,完成下级 CA 证书的安装。
- 此命令还允许安装请求续订的 CA 证书。
certutil-renewcert [-f] [-gmt] [-seconds] [-v] [-config CAMachineName\CAName] [reusekeys] RequestFile
参数- -renewcert
- 续订 CA 证书。
- -f
- Overwrites existing files or keys.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -v
- Specifies verbose output.
- -configCAMachineName\CAName
- processes the operation by using the CA specified in the configuration string (that is, CAMachineName\CAName).
- reusekeys
- 指定重复使用现有的密钥。
- RequestFile
- 指定要保存该续订请求的文件。
- -?
- Displays a list of certutil commands.
- You must specify the CAComputerName or CAName in -config CAComputerName\CAName. Otherwise, the Select Certificate Authority dialog box appears and displays a list of all CAs that are available.
- If you use -config - instead of -config CAComputerName\CAName, the operation is processed using the default CA.
- 如果联机的父 CA 不存在或不会立即颁发续订 CA 证书,请在此证书可用时使用 -installCert 命令完成续订证书的安装。
certutil-delkey [-user] [-gmt] [-seconds] [-silent] [-v] KeyContainerName [CSPName]
参数- -delkey
- 从主机中删除私钥。
- -user
- Uses the HKEY_CURRENT_USER keys or certificate store.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -silent
- 使用无声标志获得 CryptContext。
- -v
- Specifies verbose output.
- KeyContainerName
- 指定密钥的容器名称。
- CSPName
- 指定加密服务提供程序 (CSP)。
- -?
- Displays a list of certutil commands.
警告
- 注册表编辑不当可能会严重损坏您的系统。在更改注册表之前,应备份计算机上任何有价值的数据。
-
certutil -delkey 命令将删除用户或机器私钥。删除私钥后,可能应用以下任何一个方案:
- 如果以前没有备份密钥或将其存档,则被删除的密钥将无法复原。
- 如果被删除的密钥用于证书服务器签名密钥,则 CA 将被禁用且无法颁发新的 CRL,这将导致当现有的 CRL 过期时,所有由 CA 颁发的证书都将失效。可重新注册新密钥和证书来代替其他签名密钥。
- 如果被删除的密钥用于电子邮件加密,则过去接收到的电子邮件可能无法读取,除非从类似“密钥管理服务 (KMS)”的密钥管理系统才可以恢复被删除的密钥。
- 如果被删除的密钥用于文件加密,则具有适当凭证因而可以创建 Key Recovery Agent 帐户的管理员可能需要为受影响的用户单独干预并解密每个文件。
- 用 - user 从 HKEY_CURRENT_USER 根存储中删除密钥。
certutil-setreg [-user] [-gmt] [-seconds] [-v] Policy\RevocationType {+ | -} REVEXT_ASPENABLE
参数- -setreg
- 设置或编辑注册表项值。
- -user
- Uses the HKEY_CURRENT_USER keys or certificate store.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -v
- Specifies verbose output.
- Policy\RevocationType
- 指定策略模块和证书吊销配置。
- { +| -}
- 设置 (+) 或重置 (-) REVEXT_ASPENABLE 标志。
- REVEXT_ASPENABLE
- 将该扩展添加到由 CA 颁发的证书。
- -?
- Displays a list of certutil commands.
警告
- 注册表编辑不当可能会严重损坏您的系统。在更改注册表之前,应备份计算机上任何有价值的数据。
注意
- You must restart the certification authority for this change to take effect. For more information on restarting Certificate Services, see Start, stop, pause, resume, or restart a service.
certutil-ca.cert [-f] [-gmt] [-seconds] [-split] [-v] [-config CAMachineName\CAName] OutCACertFile [Index]
参数- -ca.cert
- 检索 CA 签名证书。
- -f
- Overwrites existing files or keys.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -split
- Splits the embedded Abstract Syntax Notation One (ASN.1) elements, and saves them to files.
- -v
- Specifies verbose output.
- -configCAMachineName\CAName
- processes the operation by using the CA specified in the configuration string (that is, CAMachineName\CAName).
- OutCACertFile
- 指定要写入的 CA 文件。
- 索引
- 指定要检索的 CA 证书。默认为最新的 CA。
- -?
- Displays a list of certutil commands.
- You must specify the CAComputerName or CAName in -config CAComputerName\CAName. Otherwise, the Select Certificate Authority dialog box appears and displays a list of all CAs that are available.
- If you use -config - instead of -config CAComputerName\CAName, the operation is processed using the default CA.
- 该证书中包含的公钥用于验证 CA 颁发的证书上的数字签名。
certutil-ca.chain [-f] [-gmt] [-seconds] [-split] [-v] [-config CAMachineName\CAName] OutCACertChainFile [Index]
参数- -ca.chain
- 检索 CA 签名证书和链。
- -f
- Overwrites existing files or keys.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -split
- Splits the embedded Abstract Syntax Notation One (ASN.1) elements, and saves them to files.
- -v
- Specifies verbose output.
- -configCAMachineName\CAName
- processes the operation by using the CA specified in the configuration string (that is, CAMachineName\CAName).
- OutCACertChainFile
- 将 CA 签名证书写入 PKCS #7 文件。
- 索引
- 指定要检索的 CA 证书。默认为最新的 CA。
- -?
- Displays a list of certutil commands.
- You must specify the CAComputerName or CAName in -config CAComputerName\CAName. Otherwise, the Select Certificate Authority dialog box appears and displays a list of all CAs that are available.
- If you use -config - instead of -config CAComputerName\CAName, the operation is processed using the default CA.
certutil-importcert [-f] [-gmt] [-seconds] [-v] [-config CAMachineName\CAName] CertFile
参数- -importcert
- 将证书文件导入该数据库。
- -f
- Overwrites existing files or keys.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -v
- Specifies verbose output.
- -configCAMachineName\CAName
- processes the operation by using the CA specified in the configuration string (that is, CAMachineName\CAName).
- CertFile
- 指定要导入的证书。
- -?
- Displays a list of certutil commands.
- You must specify the CAComputerName or CAName in -config CAComputerName\CAName. Otherwise, the Select Certificate Authority dialog box appears and displays a list of all CAs that are available.
- If you use -config - instead of -config CAComputerName\CAName, the operation is processed using the default CA.
- 如果不小心将证书从数据库中丢失(可能是由于从数据库的不完整备份中恢复数据库),则可用该命令行选项使其成为可吊销证书。注意,该服务器必须颁发了证书。
certutil-store [-f] [-enterprise] [-user] [-gmt] [-seconds] [-silent] [-v] [-dc DCName] CertificateStoreName [CertID [OutFile]]]
参数- -store
- 显示指定证书存储中的证书。
- -f
- Overwrites existing files or keys.
- -enterprise
- 使用本地计算机企业注册证书存储。
- -user
- Uses the HKEY_CURRENT_USER keys or certificate store.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -silent
- 使用无声标志获得 CryptContext。
- -split
- Splits the embedded Abstract Syntax Notation One (ASN.1) elements, and saves them to files.
- -v
- Specifies verbose output.
- -dcDCName
- 将一个特定的域控制器作为目标。
- CertificateStoreName
-
指定以下任一存储名称: 值 描述
ca
在“中级证书颁发机构”存储中指定证书。
my
指定颁发到当前用户的证书。
root
在“受信任的根证书颁发机构”存储中指定证书。
spc
指定软件发行商证书。
UserCreatedStore
指定用户创建的证书存储的名称。
- CertID
- 指定与令牌匹配的证书或证书吊销列表 (CRL)。
- OutFile
- 指定要写入显示的证书信息的文件。
- -?
- Displays a list of certutil commands.
- 如果没有指定 CertificateStoreName,则使用 CA 存储区。
- 使用 -user 选项为当前用户而不是本地计算机显示证书存储情况。
- CertID 可以是序列号、“安全哈希算法 (SHA-1)”证书、CRL、证书信任列表 (CTL) 或公钥哈希、数字证书索引(如 0、1 等)、数字 CRL 索引(如 .0、.1 等)、数字 CTL 索引(如 ..0、..1 等)、证书对象公用名或 CRL 颁发者公用名。其中一些可能生成多个匹配。
要查看本地计算机 NTAuth 存储中的证书,请键入:
certutil -store -enterprise NTAuth
要查看 cert 索引 37 的本地计算机“Root”存储中的证书,请键入:
certutil -store -enterprise Root 37
要查看名为“My”存储中序列号 26e0aaaf000000000004 的用户的证书,请键入:
certutil -store -user My 26e0aaaf000000000004
要查看名为 CA 的存储中索引 .11 的 CRL,请键入:
certutil -store CA .11
要查看在轻型目录访问协议 (LDAP) 位置“ldap:///CN=NTAuthCertificates,CN=Public Key Services,CN=Services,DC=corp,DC=MyCorp,DC=com”上的证书存储,请键入:
certutil -store ldap:///CN=NTAuthCertificates,CN=Public Key Services,CN=Services,DC=corp,DC=MyCorp,DC=com
将证书或 CRL 添加到本地受信任的根 CA 存储语法certutil-addstore [-f] [-enterprise] [-user] [-gmt] [-seconds] [-v] [-dc DCName] root InFile
参数- -addstore
- 将证书添加到证书存储区。
- -f
- Overwrites existing files or keys.
- -enterprise
- 使用本地计算机企业注册证书存储。
- -user
- Uses the HKEY_CURRENT_USER keys or certificate store.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -v
- Specifies verbose output.
- -dcDCName
- 将一个特定的域控制器作为目标。
- root
- 指定“受信任的根证书颁发机构”存储。
- InFile
- 指定证书或证书吊销列表 (CRL) 的文件名。
- -?
- Displays a list of certutil commands.
Certutil [{-viewstore | -viewdelstore}] [-f] [-enterprise] [-user] [-gmt] [-seconds] [-v] [-dc DCName] {my | ca | root | spc} ["CertIndex" ]
参数- -viewstore
- 查看证书存储区中的证书。
- -viewdelstore
- 从该证书存储区中删除一个证书。
- -f
- Overwrites existing files or keys.
- -enterprise
- 使用本地计算机企业注册证书存储。
- -user
- Uses the HKEY_CURRENT_USER keys or certificate store.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -v
- Specifies verbose output.
- -dcDCName
- 将一个特定的域控制器作为目标。
- my
- 显示颁发到本地计算机的证书。
- ca
- 显示“中级证书颁发机构”存储中的证书。
- root
- 显示“受信任的根证书颁发机构”存储中的证书。
- spc
- 显示软件发行商证书。
- "CertIndex"
- 指定与令牌匹配的证书或证书吊销列表 (CRL)。
- -?
- Displays a list of certutil commands.
-
要确定该证书中后面是
Cert Hash(sha1):
的 CertIndex 证书哈希值,请进行以下任一操作:
-
通过键入以下内容,转储包含旧证书的证书存储区:
certutil-store [-user] root -
通过键入以下内容,将旧证书保存到文件并转储该文件:
certutilfile.cer
-
通过键入以下内容,转储包含旧证书的证书存储区:
- 在默认情况下,-viewstore 打开 HKLM“CA”存储。可通过指定 -viewstore 后的 -user 或 -enterprise 覆盖默认,以便显示任意用户或企业存储。
- 如果您无法关闭用户接口并且使用 -viewdelstore,则可从该证书存储中删除选中的证书。
-
用户接口不支持将证书保存到文件。可运行以下语法显示所有证书,选择需要的证书,然后将其保存到一个文件:
certutil /viewstore /enterprise NTAuth *.file.cer
本地 NTAuth 存储是 Active Directory NTAuth 存储中最后“组策略”下载的结果。智能卡登录使用的存储使得当对智能卡登录失败进行疑难解答时,查看该存储是有用的。
要打开和查看当前计算机的本地 NTAuth 存储,请键入:
certutil -viewstore -enterprise NTAuth
要删除证书,请键入:
certutil -delstore -enterprise NTAuth "CertIndex"
验证存储中的所有证书语法certutil-verifystore [-enterprise] [-user] [-gmt] [-seconds] [-split] [-v] [-dc DCName] CertificateStoreName [CertID]
参数- -verifystore
- 验证存储中的证书。
- -enterprise
- 使用本地计算机企业注册证书存储。
- -user
- Uses the HKEY_CURRENT_USER keys or certificate store.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -split
- Splits the embedded Abstract Syntax Notation One (ASN.1) elements, and saves them to files.
- -v
- Specifies verbose output.
- -dcDCName
- 将一个特定的域控制器作为目标。
- CertificateStoreName
- 指定证书存储名。
- CertID
- 指定与令牌匹配的证书或证书吊销列表 (CRL)。
- -?
- Displays a list of certutil commands.
- 该命令与 -store 相似。
- 该命令验证相关私钥(即如果它们存在),并通过以下方法验证每份证书:从已安装的 CA 和根证书建立链并验证链中的所有证书,以确保它们仍然有效并且尚未吊销。
certutil-delstore [-enterprise] [-user] [-gmt] [-seconds] [-v] [-dc DCName] root CertIndex
参数- -delstore
- 从指定存储删除一个证书。
- -enterprise
- 使用本地计算机企业注册证书存储。
- -user
- Uses the HKEY_CURRENT_USER keys or certificate store.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -v
- Specifies verbose output.
- -dcDCName
- 将一个特定的域控制器作为目标。
- root
- 指定根证书存储。
- CertIndex
- 指定该哈希值。
- -?
- Displays a list of certutil commands.
-
要确定该证书中后面是
Cert Hash(sha1):
的 CertIndex 证书哈希值,请进行以下任一操作:
-
通过键入以下内容,转储包含旧证书的证书存储区:
certutil-store [-user] root -
通过键入以下内容,将旧证书保存到文件并转储该文件:
certutilfile.cer
-
通过键入以下内容,转储包含旧证书的证书存储区:
certutil-delstore [-enterprise] [-user] [-gmt] [-seconds] [-v] [-dc DCName] root -user CertIndex
参数- -delstore
- 从指定存储删除一个证书。
- -enterprise
- 使用本地计算机企业注册证书存储。
- -user
- Uses the HKEY_CURRENT_USER keys or certificate store.
- -gmt
- Displays time as Greenwich mean time.
- -seconds
- Displays time with seconds and milliseconds.
- -v
- Specifies verbose output.
- -dcDCName
- 将一个特定的域控制器作为目标。
- root
- 指定根证书存储。
- -user
- 指定 HKEY_CURRENT_USER 证书存储。
- CertIndex
- 指定该哈希值。
- -?
- Displays a list of certutil commands.
-
要确定该证书中后面是
Cert Hash(sha1):
的 CertIndex 证书哈希值,请进行以下任一操作:
-
通过键入以下内容,转储包含旧证书的证书存储区:
certutil-store [-user] root -
通过键入以下内容,将旧证书保存到文件并转储该文件:
certutilfile.cer
-
通过键入以下内容,转储包含旧证书的证书存储区:
-
Certutil -delstore 仅在删除证书和 CRL 时有效。必须使用 -delkey 删除密钥。
警告
- certutil -delkey 命令将删除用户或机器私钥。删除完毕后,可能应用下列任何一种方案:
如果以前没有备份密钥或将其存档,则被删除的密钥将无法复原。
如果被删除的密钥用于证书服务器签名密钥,则 CA 将被禁用且无法颁发新的 CRL,这将导致当现有的 CRL 过期时,所有由 CA 颁发的证书都将失效。可重新注册新密钥和证书来代替其他签名密钥。
如果被删除的密钥用于电子邮件加密,则过去接收到的电子邮件可能无法读取,除非从类似“密钥管理服务 (KMS)”的密钥管理系统才可以恢复被删除的密钥。
如果被删除的密钥用于文件加密,则具有适当凭证因而可以创建 Key Recovery Agent 帐户的管理员可能需要为受影响的用户单独干预并解密每个文件。
用 - user 从 HKEY_CURRENT_USER 根存储中删除密钥。
示例要删除根存储的第五个证书,请键入:
certutil -delstore root 5
格式图例 格式 意义斜体
用户必须提供的信息
粗体
用户必须像显示的一样准确键入的元素
省略号 (...)
可在命令行中重复多次的参数
在括号 ([]) 之间
可选项目
在大括号 ({}) 之间;将选项用管线 (|) 隔开。例如:{even|odd}
用户必须从中只选择一个选项的选项组
Courier font
代码或程序输出