Converting a PEM (Privacy Enhanced Mail) certificate to DER (Distinguished Encoding Rules) format can be useful if you wish to install the certificate on a server or device that requires the DER format. Here are the steps you need to follow to carry out this conversion:
Prerequisites
Before you begin, ensure that you have the following files:
- Your PEM certificate (usually with the extension .pem or .crt)
- Your private key (usually with the extension .key)
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 - certificate
Run the following command in the console or terminal to convert your PEM certificate to a DER certificate:
openssl x509 -outform der -in certificate.pem -out certificate.der
An overview of the components of this command:
- certificate.pem - the name of your PEM certificate file.
- certificate.der - the name of the DER file you wish to create.
Once you have run this command, you should have a .der file that you can install on your server or device.
Note: The DER format only supports a single certificate or key and cannot be used for a certificate chain. If you have a certificate chain, you must convert each certificate individually.
Conversion process - private key
openssl rsa -outform der -in privateKey.pem -out privateKey.der
An overview of the components of this command:
- privateKey.pem - for the name of your private key file.
- privateKey.der - for the name of the DER file you wish to create for the private key.
Once you have run this command, you should have a .der file for your private key, which you can install on your server or device.