Skip to content

Save server certificate to your local machine using bash

To save a server certificate to your local machine, we can use openssl and read from the https port 443 and save it using echo.


if [ ! -e "$file" ] ; then
    mkdir -p "${file%/*}" && touch "$file"

echo QUIT | openssl s_client -showcerts -connect $HOST:443 -servername $HOST 2>/dev/null | openssl x509 -text > file

Save the above script to a file called and give permissions.

chmod +x

Run the script and open the directory to see the .crt file getting saved.

See also  View processes list in tree format in Linux

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.