Remote IT Support!! Please contact us

For Any Remote Support,Implementation/Upgrade Projects,Queries,Collaborations please mail us at support@funoracleapps.com

Shell Script to find the Expiry Date of a Certificate using orapki

No comments

Shell Script to find the Expiry Date of a Certificate using orapki




I am sharing the script to find the expiry date of the certificate and send mail 30 days before expiration.

My Certificate: Server_certificate.cer

Script:
. ~/.bash_profile
cd $INST_TOP/certs/Apache
$ORACLE_HOME/bin/orapki  cert display -cert Server_certificate.cer >/tmp/certificate_info
$ORACLE_HOME/bin/orapki  cert display -cert Server_certificate.cer |grep -i Valid > /tmp/cert_valid_txt
EXP_DATE=`cat /tmp/cert_valid_txt|cut -f2- -d':' |awk '$1=$1'`
TODAY_DATE=`date`

no_of_days_left=$(( ($(date -d "$EXP_DATE" +%s) - $(date -d "$TODAY_DATE" +%s) )/(60*60*24) ))

if [ $no_of_days_left -lt 30 ]
then
echo "-----------------------------------------------------------------------" >> /tmp/certificate_info
echo "Certificate is Going to Expire, Please get a new certificate and deploy" >> /tmp/certificate_info
mailx -s "Critical: `hostname -a` EBS Certificate is Going to Expire in 30 days" himanshu@funoracleapps.com< /tmp/certificate_info
fi




If you like please follow and comment

No comments :

Post a Comment