Cheat Sheet - OpenSSL

s_client

Pull x509 certificate

HOST=myhost
openssl s_client -connect $HOST:443 -servername $HOST </dev/null 2>/dev/null \
  | openssl x509 -noout -text

Pull x509 certificate summary

HOST=myhost
openssl s_client -connect $HOST:443 -servername $HOST </dev/null 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates -startdate -enddate

Verify TLS communication

openssl s_client -connect host:port

x509

Decode certificate from STDIN

echo "...base64encoded..." | base64 -d | openssl x509 -text -noout 

Decode certificate from file

openssl x509 -in server.crt -text -noout

Verify

Display certificate chain

openssl verify -CAfile server.crt -show_chain client.crt