I'm looking for some easy way to get intermediate certificate details from openssl s_client. I can just pipe output to openssl x509 but it takes leaf cert first. I came up with this script, it works but curios if there's simplier command to achieve the same.

echo 1 | openssl s_client -connect unix.stackexchange.com:443 -showcerts 2>/dev/null | sed -n '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/ p' | sed -n '/END CERTIFICATE/,$ p' | tail -n +2 | openssl x509 -noout -text 

You might trying something like this:

$ echo 1 | \
  openssl s_client -connect unix.stackexchange.com:443 \
    -showcerts 2>/dev/null > /tmp/chained.pem && \
  openssl crl2pkcs7 -nocrl -certfile /tmp/chained.pem | \
  openssl pkcs7 -print_certs -text -noout

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.