Last active
May 30, 2025 11:33
-
-
Save dewomser/5e48081a13c176100b57bcc3b94d869d to your computer and use it in GitHub Desktop.
Webseite / URL SSL Zertifikat prüfen
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
#!/bin/bash | |
URL="blog.fefe.de" # Ersetze mit der gewünschten Domain | |
echo "Prüfe das SSL-Zertifikat für $URL ..." | |
# SSL-Prüfung mit OpenSSL | |
CERT_INFO=$(echo | openssl s_client -connect "$URL:443" -servername "$URL" 2>/dev/null | openssl x509 -noout -dates) | |
if [[ -z "$CERT_INFO" ]]; then | |
echo "Fehler: Konnte das Zertifikat nicht abrufen!" | |
exit 1 | |
fi | |
# Ablaufdatum des Zertifikats extrahieren | |
EXPIRY_DATE=$(echo "$CERT_INFO" | grep "notAfter" | cut -d= -f2) | |
echo "Das Zertifikat läuft ab am: $EXPIRY_DATE" | |
# Überprüfen, ob das Zertifikat noch gültig ist | |
EXPIRY_TIMESTAMP=$(date -d "$EXPIRY_DATE" +%s) | |
CURRENT_TIMESTAMP=$(date +%s) | |
if [[ "$EXPIRY_TIMESTAMP" -gt "$CURRENT_TIMESTAMP" ]]; then | |
echo "✅ Das Zertifikat ist gültig!" | |
else | |
echo "❌ Das Zertifikat ist abgelaufen!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment