Skip to content

Instantly share code, notes, and snippets.

@lae
Created August 14, 2017 23:59
Show Gist options
  • Save lae/0cf641a1e8e6db6e15be806f787d595b to your computer and use it in GitHub Desktop.
Save lae/0cf641a1e8e6db6e15be806f787d595b to your computer and use it in GitHub Desktop.
#!/bin/bash
for certificate in certs/*; do
expiration_date=$(openssl x509 -noout -dates -in $certificate | grep -oP "(?<=notAfter=).*")
remaining_validity_seconds=$(($(date -d "$expiration_date" +%s) - $(date +%s)))
remaining_validity_in_days=$(($remaining_validity_seconds / 86400))
if [ $remaining_validity_in_days -lt 30 ]; then
echo $(basename $certificate .pem);
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment