2013-04-21 60 views
1

我需要創建一個新證書,然後找到它以獲取序列號(稍後使用它獲取公鑰和私鑰)。如何使用Certutil查找新認證?

如果我就與makecert工具這樣一個新的證書從微軟SDK的:

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

然後我想,證書將被保存在「我的」 ......

..但是,當我嘗試列出了「我的」證書我只得到一個條目,而不是我的新證書:

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. 

又在哪裏存儲我的新的證書?

回答

0

最後我做了我的代碼:

@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%"