Skip to content

Instantly share code, notes, and snippets.

@a-kbv
Created May 23, 2024 15:29
Show Gist options
  • Save a-kbv/610d5c520bbe788c70755e2f45537fc5 to your computer and use it in GitHub Desktop.
Save a-kbv/610d5c520bbe788c70755e2f45537fc5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Function to check SSL certificate on a domain and port
check_certificate() {
local domain=$1
local port=$2
echo "Checking SSL certificate for $domain on port $port..."
timeout 5 bash -c "echo | openssl s_client -connect ${domain}:${port} -servername ${domain} 2>/dev/null | openssl x509 -noout -dates"
}
# Ask the user for a domain name
read -rp "Enter the domain you want to check: " domain
# Predefined list of ports to check, feel free to modify
ports=(443 465 587 993 995 8443 25)
# Loop through the list of ports and check each one
for port in "${ports[@]}"; do
check_certificate "$domain" "$port"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment