is there a way to read the common name from a .pem file in my shell?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First off, the
.pemextension 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
.pemfile contains an x509 certificate,this should do the trick:
This will dump the whole certificate. The
openssl x509command has several options to suppress the fields you don’t want to see. You find those explained in the man page, under
TEXT OPTIONSYou can also choose to get shown just the ‘Subject’ of the certificate:
Example:
Let’s capture the certificate of
stackoverflow.comstraight from the serverOutputs: