简体   繁体   中英

How to create pfx using openSSL with .cer file and PKCS#8 encrypted private key

Trying to use below command

openssl pkcs12 -export -in cert.cer -inkey cert.key -out cert.pfx 

I'm seeing unable to load private key exception. openssl is expecting private key.

Private key in my case is pkcs#8 encrypted. I have password for encrypted private key. But openssl is not prompting for password.

I did made progress to convert private key to privatekey.pem using below command. I did find here

openssl pkcs8 -inform DER -in file.key -passin pass:xxxxxxxx >private_key.pem

Below are commands I used to convert to Pfx.

Converted certificate to pem

openssl x509 -inform der -in certificate.cer -out certificate.pem

converted key to pem

openssl pkcs8 -inform DER -in file.key -passin pass:xxxxxxxx >private_key.pem

converted to pfx using above key and certificate pem files. I need to use csp for my case. But it is optional.

 openssl pkcs12 -export -in certificate.pem -inkey private_key.pem -CSP "Microsoft Enhanced RSA and AES Cryptographic Provider" -out cert.pfx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM