If the .pem file contains an x509 certificate,
this should do the trick:
openssl x509 -in cacert.pem -noout -text
This will dump the whole certificate. The openssl x509
command has several options to suppress the fields you don't want to see. You find those explained in the man page, under TEXT OPTIONS
You can also choose to get shown just the 'Subject' of the certificate:
openssl x509 -in cacert.pem -noout -subject
Example:
Let's capture the certificate of stackoverflow.com straight from the server
First off, the
.pem
extension only refers to the type of encoding used in the file.The common name would be a feature of the Subject or Issuer of a certificate, and can be recognised by the lines
and lots of base64 encoded text in between.
If the
.pem
file contains an x509 certificate, this should do the trick:This will dump the whole certificate. The
openssl x509
command has several options to suppress the fields you don't want to see. You find those explained in the man page, underTEXT OPTIONS
You can also choose to get shown just the 'Subject' of the certificate:
Example:
Let's capture the certificate of
stackoverflow.com
straight from the serverOutputs: