Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a .cer file to .pfx file

Tags:

ssl

openssl

pki

My ultimate objective is to sign my exe.

For this i would need a certificate. From my company's pKI i got a .cer file and .p7b (certificate chain) file.

Now to sign an exe i need a .pfx file. So i want to convert a .cer file to .pfx file

For this i donwloaded openssl distribution.

Now issuing this command openssl pkcs12 -export -in certificatename.cer -inkey privateKey.key -out certificatename.pfx -certfile cacert.cer is resulting into unable to load certificates.

Does anyone have any hints on this ?

best Regards, Saurav

like image 200
saurav Avatar asked Apr 25 '16 08:04

saurav


1 Answers

So the trick was to perform the following steps if you want to sign an exe after you got a .cer file

  1. Convert .cer to .pem using openssl command
  2. Convert .pem to .pfx using openssl command
  3. Use signtool to sign the .exe with the .pfx file generated in the step 2.

For openssl commands to convert check this

https://www.sslshopper.com/ssl-converter.html

For signtool commands check this

https://msdn.microsoft.com/en-us/library/windows/desktop/aa388170(v=vs.85).aspx

cheers,

Saurav

like image 90
saurav Avatar answered Oct 29 '22 22:10

saurav