Created
April 19, 2026 09:11
-
-
Save istudyatuni/d5f8c9b43cd2906111b1a8f2a8a600e5 to your computer and use it in GitHub Desktop.
Check expiration of domain certificate
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 | |
| set -euo pipefail | |
| readonly DOMAIN='ENTER YOUR DOMAIN' | |
| readonly DAY_SEC=86400 | |
| expiry="$(echo | \ | |
| openssl s_client -servername "$DOMAIN" -connect "$DOMAIN:443" 2>/dev/null | \ | |
| openssl x509 -noout -enddate | \ | |
| cut -d= -f2)" | |
| expiry_sec="$(date -d "$expiry" +%s)" | |
| now_sec="$(date +%s)" | |
| days_left=$(( ($expiry_sec - $now_sec) / $DAY_SEC )) | |
| echo "Domain $DOMAIN expires at $expiry (days left: $days_left)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment