In this post we will know about how to find date of expiry and issue of SSL certificate with command line. As a system administrator it is good to know how can we get the ssl certificate information with command line. It helps you to make script and run from terminal/cron job etc.

We have created nagios plugin with the help of this command.Here in this post, we are sharing with our readers.

In your system openssl package should be installed.

In CentOS/RHEL

yum install openssl

In Debian/Ubuntu

sudo apt-get install openssl

NOTE: Replace google.com with the domain name of your choice. And the certificate should be used in Website.

Date of issue of SSL Certificate

echo "QUIT" | openssl s_client -connect google.com:443 2>/dev/null | openssl x509 -noout -startdate 2>/dev/null

Date of expiration of SSL Certificate

echo "QUIT" | openssl s_client -connect google.com:443 2>/dev/null | openssl x509 -noout -enddate 2>/dev/null

Given below is the reference from our system

sharad@linuxworld:~$ echo "QUIT" | openssl s_client -connect google.com:443 2>/dev/null | openssl x509 -noout -enddate 2>/dev/null
notAfter=Mar  3 00:00:00 2015 GMT
sharad@linuxworld:~$ 
sharad@linuxworld:~$ echo "QUIT" | openssl s_client -connect google.com:443 2>/dev/null | openssl x509 -noout -startdate 2>/dev/null
notBefore=Dec  3 11:52:24 2014 GMT
sharad@linuxworld:~$

Read Some More Articles

Leave a Reply

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