Forum Discussion

karan12_154818's avatar
karan12_154818
Icon for Nimbostratus rankNimbostratus
Jul 22, 2014

SSL certificates Expiration

I run below SSL expiration certifiacate script on LTM with 11.x version

! /bin/bash set acceptable threshold in seconds (172800 seconds = 2 days)

threshold=185920000

get today's date

this_date=

date +%s

set path to certificates

cert_path=/config/ssl/ssl.crt/

for f in $cert_path*.crt do this_cert_date_literal=

openssl x509 -in $f -noout -enddate |sed s/notAfter=//
this_cert_date=
date -d "$this_cert_date_literal" +%s

if [ $this_date -ge $(($this_cert_date - $threshold)) ]
then
    expires_when=$(((this_cert_date - $this_date) / 60 / 60 / 24))
    echo "$f is about to expire in $expires_when days"

     additional processing for expiring certs goes here 
fi

done

But get no output as such.Please suggest.

2 Replies