converting .cer to .pem returns error 'unable to load certificate'

10,945

Your certificate is already in PEM format. Just rename it from certificate.cer to certificate.pem

Share:
10,945
Green_qaue
Author by

Green_qaue

Updated on June 05, 2022

Comments

  • Green_qaue
    Green_qaue almost 2 years

    I got an email containing a cert, it looked something like:

    -----BEGIN CERTIFICATE-----

    MIIHE...

    -----END CERTIFICATE-----

    I copy/pasted that into notepad and saved it as a .cer file.

    What I need now is a .pfx file using this cert. From what I gather I need to first convert my .cer to a .pem.

    I tried converting my .cer to a .pem but that only gave error:

    OpenSSL> x509 -inform der -in C:\Users\xxx\Desktop\cert.cer -out certificate.pem

    unable to load certificate 7320:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:.\crypto\asn1\tasn_dec.c:1315: 7320:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:.\crypto\asn1\tasn_dec.c:379:Type=X509

    I read some answers that also say just changing .cer to .pem is enough, but for me that does not seem to work at all.

  • Green_qaue
    Green_qaue almost 6 years
    Hmm, is there anyway I can test that this actually works? If I save it as a .pem my comp just treats it like a .txt file and opens it in notepad. But maybe that is intended. (i.e I cope/paste into notepad and save as .pem)
  • Jitrenka
    Jitrenka almost 6 years
    Use it. that's how you find out :)