I have a .cer certificate, .key file and I would like to convert it to the .pem format.

How do I convert them to .pem?

  • 1
    That really depends on the types of the files you have. Both .cer and .key may be in PEM format already. Just open the files in your text editor of choice. If it is text with stuff like "--- BEGIN CERTIFCATE ---", then it is already PEM format. If it isn't, you'll need to find out what format you have. You can use the "file" utility, that should tell you what kind of file you're dealing with. Commented Nov 24, 2022 at 18:55
  • Also, see serverfault.com/questions/254627/… Commented Nov 24, 2022 at 18:56
  • 1
    Does this answer your question? How do I convert a .cer certificate to .pem? Commented Feb 26 at 6:48

2 Answers 2


Assuming you have the .key PK,
and .cer/.crt/.cert file in the correct format
(i think common-name is mandatory)

// in Linux

cat x.key x.cert > x.pem

// in Windows

copy /b x.key+x.cert x.pem
  • This is valid if the files are already in a PEM format and just having a different name suffix (refer to the comment to the question). Commented Feb 26 at 6:47

I used openssl to do the conversion and it works.

Convert 'certificate.cer' to 'certificate.pem'

openssl x509 -inform DER -in certificate.cer -out certificate.pem

Convert 'yourkeyfile.key' to 'yourkey.pem'

openssl rsa -in yourkeyfile.key -out yourkeyfile.pem

Bundle both certificate.pem and yourkey.pem as a single cert+key.pem

cat certificate.pem yourkey.pem > cert+key.pem
  • welcome, I would suggest that you edit your question and add more information and some references to verify your solution.
    – djdomi
    Commented Feb 27 at 18:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .