Created
May 11, 2021 06:32
-
-
Save mrunderline/82f6fa22e86c0fc307c793d701d701ba to your computer and use it in GitHub Desktop.
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 | |
website="$1" | |
certificate_file=$(mktemp) | |
echo -n | openssl s_client -servername "$website" -connect "$website":443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $certificate_file | |
date=$(openssl x509 -in $certificate_file -enddate -noout | sed "s/.*=\(.*\)/\1/") | |
date_s=$(date -d "${date}" +%s) | |
now_s=$(date -d now +%s) | |
date_diff=$(( (date_s - now_s) / 86400 )) | |
echo "$website will expire in $date_diff days" | |
rm "$certificate_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment