Last active
November 8, 2017 23:26
-
-
Save prasincs/8e5d250b1df73605fad5700c295713ec to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
CURDIR="$( cd "$( dirname "$0" )" && pwd )" | |
DOMAIN=$1 | |
mkdir -p $CURDIR/zones/$DOMAIN | |
zone_id=$(aws route53 list-hosted-zones-by-name --dns-name $DOMAIN --output text | grep HOSTEDZONES | awk '{gsub("/hostedzone/","",$3); print $3}'| head -n1) | |
domains=$(aws route53 list-resource-record-sets --hosted-zone-id $zone_id --query 'ResourceRecordSets[*].Name' --output text | xargs -n1 | sort -u | xargs) | |
for addr in $(echo $domains); do | |
addr=$(echo $addr | tr -d '"' ) | |
# remove the last character | |
addr=${addr::-1} | |
end_date=$(timeout 1 openssl s_client -connect $addr:443 | openssl x509 -noout -enddate) | |
if [ "x" != "x$end_date" ]; then | |
echo $addr, expiry=$end_date | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment