Skip to content

Instantly share code, notes, and snippets.

@artbikes
Created March 28, 2014 22:59
Show Gist options
  • Save artbikes/9844738 to your computer and use it in GitHub Desktop.
Save artbikes/9844738 to your computer and use it in GitHub Desktop.
#!/bin/bash
EXPIRATION=$( echo |\
openssl s_client -connect $1:443 2>/dev/null |\
openssl x509 -noout -dates |\
tail -1 |\
sed 's/notAfter=\(.*\)/\1/' )
EXP_EPOCH=$(gdate --date="$EXPIRATION" +%s)
TODAY=$(gdate +%s)
# Days until expiration
echo $(( ($EXP_EPOCH - $TODAY )/(60*60*24) ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment