checkcertdomains.sh (1372B)
1 #!/bin/sh 2 # check if certificate of domains expires in N days. 3 4 #ISC License 5 # 6 #Copyright (c) 2011-2018 Hiltjo Posthuma <hiltjo@codemadness.org> 7 # 8 #Permission to use, copy, modify, and/or distribute this software for any 9 #purpose with or without fee is hereby granted, provided that the above 10 #copyright notice and this permission notice appear in all copies. 11 # 12 #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 #WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 #MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 #ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 #WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 #ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 #OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 20 days=30 21 end=$((3600*24*days)) 22 tmpfile=/tmp/checkcert_$$ 23 24 while read -r d; do 25 printf 'Checking %s... ' "$d" 26 printf '' | \ 27 openssl s_client -no_ticket -tls1_2 \ 28 -servername "$d" -connect "$d:443" > "$tmpfile" 2>/dev/null 29 openssl x509 -noout -checkend "$end" < "$tmpfile" 30 printf '\n%s: expires in %s days? %s\n' "$d" "$days" "$?" 31 done << !__EOF__ 32 adamsgaard.dk 33 www.adamsgaard.dk 34 src.adamsgaard.dk 35 andersdamsgaard.dk 36 www.andersdamsgaard.dk 37 andersdamsgaard.com 38 www.andersdamsgaard.com 39 !__EOF__ 40 41 rm -f "$tmpfile"