Skip to content

Instantly share code, notes, and snippets.

@istudyatuni
Created April 19, 2026 09:11
Show Gist options
  • Select an option

  • Save istudyatuni/d5f8c9b43cd2906111b1a8f2a8a600e5 to your computer and use it in GitHub Desktop.

Select an option

Save istudyatuni/d5f8c9b43cd2906111b1a8f2a8a600e5 to your computer and use it in GitHub Desktop.
Check expiration of domain certificate
#!/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