Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

makecert requesting password

Given the following powershell function:

function CreateRootCertificate($certificateName, $path, $certificatePassword){
    makecert -r -pe -n "CN=$certificateName" -sky exchange $path\$certificateName.cer -sv $path\$certificateName.pvk
    pvk2pfx.exe -pvk $path\$certificateName.pvk -spc $path\$certificateName.cer -pfx $path\$certificateName.pfx -po $certificatePassword
}

makecert is prompting me to enter the certificate password. From what I understand it wont do this, if the *.pvk file already exists, and has a password set upon it.

SO my question is, how do I split my single makecert command in two separate commands, one to create the *.pvk and another to create the *.cer?

Many Thanks

like image 761
Mick Walker Avatar asked Oct 20 '22 16:10

Mick Walker


1 Answers

“Makecert.exe” will always prompt for password when creating a private key.

One way around this prompt may be to write code/macro, to find the password input window and enter your password in it.

The other is to use OpenSSL. In OpenSSL use

openssl genrsa -aes128 -passout pass:password -out $certificateName.pvk 2048

to generate a private key with passphrase.

If you do work with certificates a lot, I would recomend to forget “makecert.exe” altogether and use OpenSSL instead.

like image 170
Jan Chrbolka Avatar answered Nov 15 '22 07:11

Jan Chrbolka