A PEM certificate file includes Base64-encoded data and one or more pairs of " -----BEGIN CERTIFICATE----- " and " -----END CERTIFICATE----- " lines. You can use text editors such as Notepad++ to open PEM certificate files. This topic describes how to convert certificates in different formats to the PEM format.

Convert certificates in the CER and CRT formats to the PEM format

To convert certificates in the CER and CRT formats to the PEM format, you can change the file extension of the certificate file. For example, you can rename the server.crt certificate as server.pem to convert it to the PEM format.

Convert certificates in the PFX format to the PEM format

Certificates in the PFX format are used in Windows Server systems. To convert the certificates to the PEM format, you can use the OpenSSL tool.

For example, you can run the following OpenSSL commands to convert the certname.pfx certificate to the PEM format:

  • Extract the private key: openssl pkcs12 -in certname.pfx -nocerts -out key.pem -nodes
  • Extract the certificate content: openssl pkcs12 -in certname.pfx -nokeys -out cert.pem

Convert certificates in the P7B format to the PEM format

Certificates in the P7B format are used in Windows Server systems and Tomcat servers. To convert the certificates to the PEM format, you can use the OpenSSL tool.

Perform the following operations:
  1. Convert certificates in the P7B format to the CER format. For example, run the openssl pkcs7 -print_certs -in incertificat.p7b -out outcertificate.cer command to convert the incertificat.p7b certificate to the outcertificate.cer certificate.
  2. Extract the certificate content from [-----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----] in the outcertificat.cer certificate.
  3. Save the certificate in the PEM format.

Convert certificates in the DER format to the PEM format

Certificates in the DER format are used in Java platforms. To convert the certificates to the PEM format, you can use the OpenSSL tool.

For example, you can run the following OpenSSL commands to convert the certificate.cer certificate to the PEM format:
  • Extract the certificate content: openssl x509 -inform der -in certificate.cer -out certificate.pem
  • Extract the private key: openssl rsa -inform DER -outform PEM -in privatekey.der -out privatekey.pem