Guides 7 min read Published January 27, 2025

How to Build Custom Automated SSL Certificate Monitoring with Bash, Python, and Webhooks

Tutorial on building automated SSL certificate expiration checkers using Bash cron jobs, Slack webhooks, and public monitoring APIs.

🛡️
CheckSSLExpiry Security Research Team SSL/TLS Security & Cryptographic Reliability

⚡ Check Your Domain's SSL Expiry Right Now

Instant certificate inspection and zero-login automated email alerts.

Bash Script to Alert on Expirations Below 14 Days

#!/bin/bash
DOMAIN="example.com"
EXPIRY_DATE=$(echo | openssl s_client -servername "${DOMAIN}" -connect "${DOMAIN}:443" 2>/dev/null | openssl x509 -noout -enddate | cut -d= -f2)
EXPIRY_EPOCH=$(date -d "${EXPIRY_DATE}" +%s)
NOW_EPOCH=$(date +%s)
DAYS_LEFT=$(( (EXPIRY_EPOCH - NOW_EPOCH) / 86400 ))

echo "Domain: ${DOMAIN} has ${DAYS_LEFT} days remaining."

if [ "${DAYS_LEFT}" -lt 14 ]; then
    # Send alert to Slack Webhook
    curl -X POST -H 'Content-type: application/json' \
        --data "{\"text\":\"⚠️ CRITICAL: SSL certificate for ${DOMAIN} expires in ${DAYS_LEFT} days!\"}" \
        "${SLACK_WEBHOOK_URL}"
fi

The Smarter Alternative: Zero-Maintenance Passwordless Monitoring

Instead of maintaining self-hosted cron scripts that can fail if the monitoring box loses power or internet connectivity, you can use CheckSSLExpiry's free passwordless monitoring service.

⚡ Set Up Free 24/7 Monitoring in 5 Seconds

Automatic alerts at 30, 14, 7, 3, 1 days & day 0 with zero servers to manage.

Enable Free SSL Alerts →
Advertisement
Ad Space Reserved