Matt's Grand Ideas

How to use telnet to test SSL/https websites

Pinterest LinkedIn Tumblr

OK, here’s the problem… you want to test a website by sending custom headers, but the website uses https. You want to use telnet to test SSL. Normally you’d just telnet to port 80 like so:

telnet www.somesite 80
GET /index.html HTTP/1.1
Host: www.somesite

(Note you need to press enter twice at the end)

This would be a valid HTTP GET request and you’d see the server’s response headers and response data. But with an SSL website, this won’t work at all. What do you do?

Use OpenSSL of course. The OpenSSL s_client program works perfectly here:

openssl s_client -connect www.somesite:443

(watch the ssl certificate details scroll by)

GET /index.html HTTP/1.1 Host: www.somesite

(again you need to press enter twice)

VOILA! But one gotcha… when using telnet the web server would patiently wait for me to type out the request completely. Some versions of s_client do NOT. So type out your request in a text editor and have it ready to paste in right after the SSL cert details scroll by.

I’ve only tried it with Ubuntu Linux but it should work on any Linux and Mac OS if you have OpenSSL installed. There is a version for Windows too.

Thanks Ng, one of the phenomenal Canonical sysadmins for this tip. Also, Steve Langasek, the Ubuntu release manager suggests GnuTLS. It works similarly:

gnutls-cli www.somesite

No need to specify a port number or use any command line options. Note that like s_client you need to be ready to paste your request in. apt-get install gnutls-bin will take care of you here.

Do you want to use telnet to test SPDY or HTTP/2 websites? Here’s a tool to help with that.

Web guy, big thinker, loves to talk, teach and write. I make technology easier to use @ John Deere ISG.

Pin It