askvity

How to convert crt to PEM?

Published in Certificate Conversion 2 mins read

To convert a .crt file to .pem format, you can use the OpenSSL command-line tool. The command is straightforward and efficient.

Using OpenSSL to Convert CRT to PEM

OpenSSL is a powerful and widely used cryptography toolkit. It can handle various certificate formats. Here's how to use it to convert a .crt file to a .pem file:

  1. Open your command-line interface. This could be Terminal on macOS or Linux, or Command Prompt/PowerShell on Windows.

  2. Type the following command:

    openssl x509 -in cert.crt -out cert.pem
    • openssl x509: This invokes the OpenSSL's X.509 certificate processing tool.
    • -in cert.crt: This specifies the input certificate file (the .crt file you want to convert). Replace cert.crt with the actual filename if it's different.
    • -out cert.pem: This specifies the output file name for the converted certificate (the .pem file). You can choose any name you like, but the .pem extension is conventional.
  3. Execute the command. OpenSSL will read the cert.crt file and output the converted certificate in PEM format to a file named cert.pem.

What are .CRT and .PEM files?

  • .CRT: A .crt file is a certificate file, often in binary DER format or text-based PEM format.
  • .PEM: A .pem file is a text-based certificate file encoded in Base64, enclosed between "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----" lines. PEM format can store certificates, private keys, and other cryptographic data.

Converting other formats to PEM

OpenSSL can also convert other certificate formats to PEM:

Input Format Command
CER openssl x509 -in cert.cer -out cert.pem
DER openssl x509 -in cert.der -out cert.pem

Related Articles