I want to download the ssl certificate from, say https://www.google.com, using wget or any other commands. Any unix command line? wget or openssl?

link|improve this question

77% accept rate
feedback

2 Answers

up vote 13 down vote accepted

I found the answer. Openssl provides it.

openssl s_client -connect ${REMHOST}:${REMPORT}

link|improve this answer
feedback

In order to download the certificate, you need to use openssl with the -showcerts option, like so:

openssl s_client -showcerts -connect $SERVERNAME:443 >/tmp/$SERVERNAME.cert </dev/null

That will save the certificate to /tmp/$SERVERNAME.cert.

It looks like it also writes the cert to stdout without -showcerts, but -showcerts specifically says it will display the certificate so it seems to be the canonical way to get it. The </dev/null makes it so that the connection is closed, rather than sitting there waiting for you to send a valid HTTP request to the server.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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