1

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 
0

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 agree to our terms of service, privacy policy and cookie policy

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