Created
March 27, 2014 11:46
-
-
Save chrjoh/9805762 to your computer and use it in GitHub Desktop.
loop over rows of hosts in a file and fetch the cerificate of each host and display the cerificate date's
This file contains 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/sh | |
# | |
# usage: check_dates_all_hosts.sh hosts_file | |
# where hosts_:file is a file with one hostename per row | |
# | |
function get_cerificate { | |
REMHOST=$1 | |
REMPORT=${2:-443} | |
echo |\ | |
openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 |\ | |
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' |\ | |
openssl x509 -noout -subject -dates | |
} | |
cat $1 | while read line | |
do | |
echo $line | |
get_cerificate $line | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment