#!/bin/sh if [ $# -le 1 ]; then echo "$0 usage: [days count] file1_with_domains file2_with_domains" exit 1 fi DAYS=$1 shift 1 NOW=`date -d "+$DAYS" +%s` while [ $# -gt 0 ]; do file=$1 shift 1 if [ -e $file ]; then cat $file | while read host do DATE=`echo "" | openssl s_client -connect $host 2>/dev/null | openssl x509 -noout -enddate | sed -e 's:notAfter=::'` TIMESTAPM=`date -d "$DATE" +%s` if [ $NOW -gt $TIMESTAPM ]; then echo "$host is expired less than $DAYS (`LC_ALL=C date -d @$TIMESTAPM`)" fi done else echo "can't open $file" fi done