如何使用Certutil查找新证书? [英] How to locate new certification using Certutil?

查看:1538
本文介绍了如何使用Certutil查找新证书?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个新的证书,然后找到它以获取序列号(以后使用它获取公共密钥和私钥)。

I need to create a new cert and then locate it to obtain the serial number (to use it later to get the public and private keys).

如果我使用Microsoft SDK的makecert实用程序创建新证书,如下所示:

If I make a new certificate with makecert utility from Microsoft SDK's like this:

makecert -r -pe -a sha1 -n "CN=ElektroSoft" -b 01/01/2013 -e 01/01/2050 -ss my -$ individual 

然后我想证书将存储在我的...

Then I suppose that cert will be stored in "my"...

..但是当我试图列出我的证书,我只得到一个条目,并不是我的新证书:

..But when I try to list the "my" certificates I only get one entry, and is not my new certificate:

C:\>CERTUTIL -store my

my
================ Certificado 0 ================
Número de serie: 586a7358ebdce8854def26875f0f38ab
Emisor: CN=localhost
NotBefore: 22/02/2013 4:43
NotAfter: 22/02/2018 2:00
Sujeto: CN=localhost
La firma coincide con la clave pública
Certificado raíz: el sujeto coincide con el emisor
Plantilla:
Hash de cert(sha1): 1b 92 19 ef 19 ce d1 09 ad 87 13 73 56 0c cf 0a 57 29 cf 81
 Contenedor de claves = IIS Express Development Certificate Container
 Nombre de contenedor exclusivo: fad662b360941f26a1193357aab3c12d_a61f2a11-eaf9
-4c14-9a63-d3613bf3bd2c
 Proveedor = Microsoft RSA SChannel Cryptographic Provider
Prueba de cifrado correcta
CertUtil: -store comando completado correctamente.

那么在哪里存储我的新证书?

Then where is stored my new certificate?

推荐答案

最后我做了我的代码:

@Echo OFF
Setlocal enabledelayedexpansion


Set "Name=ElektroSoft"
Set "Password=Elektro"
Set "InitialDate=01/01/2013"
Set "ExpireDate=01/01/2050"
Set "SerialNumber=%Random%%Random%%Random%%Random%%Random%"


:: Make certificate
makecert -r -pe -a sha1 -n "CN=%Name%" -b "%InitialDate%" -e "%ExpireDate%" -$ individual -sr LocalMachine -ss my -cy authority -# "%SerialNumber%" "%Name%.cer"


:: Export certificate
For /F "Tokens=2 delims=:" %%# in ('certutil -store my') DO (
    if "%%#" NEQ " CN=%Name%" (Set "SerialNumberHash=%%#") ELSE (
        certutil -exportPFX -p "%Password%" my "!SerialNumberHash: =!" "%Name%.pfx"
        Pause&Exit))


:: Check certificate
REM certutil -store my


:: Delete certificate
REM certutil -delstore MY "%Name%"

这篇关于如何使用Certutil查找新证书?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆