Created
June 3, 2019 22:41
-
-
Save incfly/5439e156867fa634197a72a3180fb91e to your computer and use it in GitHub Desktop.
Check Istio Root Certificate Valiness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rootcert() { | |
echo "Fetching root cert from istio-system namespace..." | |
kubectl get secret -n istio-system istio-ca-secret -o yaml | awk '/ca-cert/ {print $2}' | base64 --decode > ca.cert | |
if [[ ! -f ./ca.cert ]]; then | |
echo "failed to get cacert, check the istio installation namespace." | |
return | |
fi | |
rootDate=$(openssl x509 -in ca.cert -noout -enddate | cut -f2 -d'=') | |
rootSec=$(date -d "${rootDate}" '+%s') | |
nowSec=`date '+%s'` | |
remainDays=$(echo "(${rootSec} - ${nowSec}) / (3600 * 24)" | bc) | |
cat << EOF | |
Your Root Cert will expire after | |
${rootDate} | |
Current time is | |
$(date) | |
===YOU HAVE ${remainDays} DAYS BEFORE THE ROOT CERT EXPIRED!===== | |
EOF | |
} | |
rootcert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment