Ad Widget

Collapse

Script bash to monitor ssl jks certificates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lolodu13
    Junior Member
    • Aug 2018
    • 8

    #1

    Script bash to monitor ssl jks certificates

    Hi guys,

    this script checks if the certificate inside the jks trustore is still valid before 30 days.
    tell me what you think, if I can do better, shorter?


    ------------------------------------------------------
    #!/bin/sh

    CertExpires=`keytool -list -v -keystore /opt/cloudera/security/jks/bigdata-ca-truststore.jks -storepass PASS-alias 'cn=root ca' |grep 'Valid from' |sed 's/.*until: //'`

    date -d "`echo $CertExpires -30day`" +"%s" > timestamp_rootto30d
    date +"%s" > datedujour

    end30=`cat timestamp_rootto30d`
    datejour=`cat datedujour`

    if [ $datejour -ge $end30 ]
    then
    echo 'Certificate will expire';
    else
    echo 'Certificate will not expire before 30 days'
    fi
    Last edited by lolodu13; 13-09-2018, 17:45.
Working...