检测域名的证书是否到期
- 确保系统已经安装openssl
yum install openssl -y
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
- 使用方法
bash PATH/sslcheck.sh www.baidu.com 443