Converting a PFX (Personal Information Exchange) or PKCS#12 certificate to PEM (Privacy Enhanced Mail) format can be useful if you wish to install the certificate on a server or device that requires the PEM format. Here are the steps you need to follow to carry out this conversion:
Prerequisites
Before you begin, ensure that you have the following file:
- Your PFX/PKCS#12 certificate (usually with the extension .pfx or .p12)
You will also need OpenSSL, a powerful tool for managing certificates and keys. OpenSSL comes pre-installed on most Linux distributions and can also be installed on Windows and macOS.
Conversion process
Run the following command in the console or terminal to convert your PFX/PKCS#12 certificate to a PEM certificate:
openssl pkcs12 -in certificate.pfx -out certificate.pem -nodes
An overview of the components of this command:
- certificate.pfx - the name of your PFX/PKCS#12 certificate file.
- certificate.pem - the name of the PEM file you wish to create.
When you run this command, you will be prompted to enter the password for your PFX/PKCS#12 certificate. This password was set when the PFX/PKCS#12 certificate was created.
The `-nodes` switch in the command means that the private key is not encrypted, which is desirable in most cases. If you wish to encrypt the private key, omit this switch.
Once you have run this command, you should have a .pem file that you can install on your server or device. This file contains both the certificate and the private key.