check ssl certificate details in linux

How to Check Remote SSL Certificate in Linux

Most websites use SSL certificates to encrypt website traffic and data. Sometimes you may need to view certificate details to ensure that it is valid. You can easily do this from command line using one of the many tools offered by Linux. In this article, we will learn how to check remote SSL certificate in Linux.


How to Check Remote SSL Certificate in Linux

Here are the different commands to check remote SSL certificate of domain example.com in Linux.


1. Using OpenSSL

You can use following OpenSSL command to check details of remote SSL certificate in Linux. Replace example.com with the domain whose SSL certificate you want to check.

$ echo | openssl s_client -showcerts -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -inform pem -noout -text

In this case, the first openssl command establishes SSL connection and pipes certificate in PEM format to second openssl command.



2. Using cURL

You can also use cURL command to check a given website’s SSL certificates.

$ curl --insecure -vvI https://www.example.com 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }'


3. Using nmap

You can also use nmap command to get SSL details.

$ nmap -p 443 --script ssl-cert example.com

Each of the above commands, when run, will display all the information present in the specified website’s SSL certificates such as issuer, algorithm, date of expiry, etc. that you can use to analyze the SSL certificate.

In this article, we have learnt how to get SSL certificate details of a website from command line. You can run the above commands from any Linux system that has internet connection.

Also read:

How to Enable SSL for MySQL in Windows
How to Append One File to Another in Linux
How to Rename Git Tag
How to Clone Large Git Repository
How to Clone Single Git Branch

One thought on “How to Check Remote SSL Certificate in Linux

Leave a Reply

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