All the actions below are performed in a Windows 10 PC running Linux subsystem (Ubuntu 20.04)
Convert PEM, CRT, CER to PFX
Requirements
- The certificate’s private key
- A PEM file (.pem, .crt, .cer)
The following command will generate a .pfx file from your .key and .pem file:
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.pem
- Replace “privateKey.key” with the name of your private key file.
- Replace “certificate.pem” with the name of your certificate file.
- Optionally change “certificate.pfx” to your desired name for the .pfx file.
- Enter, re-enter and export password.
Your .pfx file will be available at the path used in the command prompt.
Convert PEM to CRT
The following command will convert .PEM file to .CRT
openssl x509 -outform der -in certificate.pem -out certificate.crt
Convert PFX to PEM
The following command will extract the private key without a password from your .PFX file (requires certificate password)
openssl pkcs12 -in Your_Certificate.pfx -out privateKey.key -nocerts -nodes
The following command will generate a .PEM certificate file from your .PFX file which will include any intermediate and root certificates that may be included in the .PFX file (requires certificate password)
openssl pkcs12 -in Your_Certificate.pfx -out Your_Certificate.pem -nokeys -clcerts
The .key and .pem files will be available at the path used in the command prompt.
If you’ve found my post helpful, I’d love it if you bought me a coffee! ☕😊
