检测域名的证书是否到期

end_time=`echo | openssl s_client -servername $1 -connect $1:$2 2>/dev/null | openssl x509 -noout -enddate| cut -d "=" -f 2`
get_time=`date  +%s`
expiry_time=`date -d "$end_time" +%s`

   if [[ $get_time < $expiry_time ]];then
    s_time=$(expr $expiry_time - $get_time)
    h_time=$(expr $s_time / 3600)
    expr $h_time / 24
   else
   
    echo "certificate has expired or is not yet valid"
  fi