How to check SSL certificate expiration time through shell script

 

In this blog we will learn "How to check SSL certificate  number of days for expiration of our domain"

I am going to show here in a Linux environment by using Shell script.

 Create file by the name checkssl.sh

- sudo nano checkssl.sh

Code- Copy this code and save file.

data=`echo | openssl s_client -servername $1 -connect $1:${2:-443} 2>/dev/null | openssl x509 -noout -enddate | sed -e 's#notAfter=##'`

ssldate=`date -d "${data}" '+%s'`

nowdate=`date '+%s'`

diff="$((${ssldate}-${nowdate}))"

echo $((${diff}/86400))

Output- You will get result as below



Comments

Popular posts from this blog

Deploying App through AWS EKS by using ingress and fargate

How to enable AWS EBS Volume snapshots encryption

Reset Jenkins Admin Password