How to save a remote server SSL / TLS certificate locally as a file


In linux you can just use the openssl commandline tools to download any certificate from a remote web-server and store it in a local file.

Show the certificate chain and public key of a web-server

openssl s_client -connect slash4.de:443 -showcerts

To directly extract the certificate and save it to a file you can use these commands (all in one line):

openssl s_client -connect slash4.de:443 -showcerts </dev/null 2>/dev/null | openssl x509 -outform PEM > slash4.pem

Leave a comment

Your email address will not be published. Required fields are marked *