13

I have my localhost TSL/SSL certificate from Chrome stored to a .PEM file. Was wondering how do I use the oppenssl command to decode it into a list of human-readable fields.

Googling this only returned info on how to work with the private key.

There are online utilities for decoding a public key, but I need a method I can easily access programatically using Python. I couldn't find anyway to do this using a library, so I thought the openssl command might work.

The public key text in the .PEM file is the standard public key format that does work in the online decoding utilities.

Thank you!

1
  • 2
    You may want to change your title to state that you want to view a certificate, not a public key. Commented Apr 26, 2021 at 5:43

2 Answers 2

21

If you want to view a public key in PKCS#1 format, you can use:

openssl rsa -pubin -in <file> -text
2
  • 2
    I think this should be the accepted answer if the input is indeed just the public key in a file. because if you don't add the -pubin parameter, openssl rsa ... will emit something like asn1_check_tlen:wrong tag and asn1_d2i_ex_primitive:nested asn1 error. If you have full X509 certificate instead of just the public key, then openssl x509 ... will show the data even without the -pubin parameter. Commented Aug 9, 2022 at 14:03
  • 1
    @MikkoRantalainen I changed it to this answer Commented Dec 6, 2023 at 0:15
14

how do I use the oppenssl command to decode it into a list of human-readable fields.

openssl x509 -in NAME.pem -text -noout

Replace 'NAME' with whatever filename your .pem file has.

1
  • 5
    That shows a X509 certificate, not public key. Commented Apr 26, 2021 at 5:42

You must log in to answer this question.

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