Created
March 6, 2016 16:42
-
-
Save yoursunny/d9c5008fe2ec3d7eb4c3 to your computer and use it in GitHub Desktop.
NDN testbed certificate expiry check
This file contains 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 | |
TPMDIR=/tmp/ndntestbed-certexpiry_$(date +%s) | |
NOW=$(date -u +%s) | |
mkdir -p $TPMDIR | |
export HOME=$TPMDIR | |
pushd $TPMDIR >/dev/null | |
curl -s http://ndncert.named-data.net/cert/list/ > certs.txt | |
cat certs.txt | sed 's~/[^/]*/ID-CERT/.*~~' | sort -u | \ | |
while read -r ID; do | |
CERT=$(cat certs.txt | grep -F $ID/ksk | sort | tail -1) | |
curl -s -G --data-urlencode "name=$CERT" http://ndncert.named-data.net/cert/get/ | \ | |
ndnsec-cert-install - 2>/dev/null | |
EXPIRY=$(ndnsec-dump-certificate -p $CERT | grep NotAfter | awk '{printf("%04d-%02d-%02d %02d:%02d:%02d", substr($2,1,4), substr($2,5,2), substr($2,7,2), substr($2,10,2), substr($2,12,2), substr($2,14,2))}') | |
EXPIRYT=$(date -u -d "$EXPIRY" +%s) | |
echo -n "$CERT $EXPIRY " | |
if [[ $EXPIRYT -lt $NOW ]]; then | |
echo EXPIRED | |
else | |
echo OK | |
fi | |
done | |
popd >/dev/null | |
rm -rf $TPMDIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment