You are here: Home / Software / OpenSSL commandline

OpenSSL commandline

In the good old days, the internet was a nice playground. Everything on the wire was plain text. A simple wirecapture was enough to understand the protocol. Debugging involved using telnet.

To check what a webserver return

echo -e "GET / HTTP/1.1\\n\n" |\
nc 80

Then came the encryption, which makes a lot of sense. But testing any service becomes a bit more complicated. Luckily openssl comes with a nice commandline tool: openssl.

openssl s_client -connect

To make the same example as before, you can’t simply replace the echo. openssl will terminate the connection as soon as the EOF ist sent via stdin. That is before the response is retrieved. So we make the echo in a subshell and add a sleep

(echo -e "GET / HTTP/1.1\\n\n"; sleep 5) |\
openssl s_client -connect

Another nice thing is the check of certifcates. For example expiration date.

echo ""  |\
openssl s_client -connect |\
  openssl x509 -noout -enddate

Here the immediate termination by openssl is fine, we already got the cert.