代码拉取完成,页面将自动刷新
#/bin/bash
HOST=("im.example.cn" "www.example.com")
PORT="443"
for url in "${HOST[@]}"
do
# 获取证书信息
cert_info=$(echo | openssl s_client -servername $url -connect $url:$PORT 2>/dev/null | openssl x509 -noout -dates)
# 提取证书有效期的起止日期
start_date=$(echo "$cert_info" | grep -i "notBefore" | awk -F '=' '{print $2}')
end_date=$(echo "$cert_info" | grep -i "notAfter" | awk -F '=' '{print $2}')
# 将日期转换为时间戳
start_timestamp=$(date -d "$start_date" +%s)
end_timestamp=$(date -d "$end_date" +%s)
current_timestamp=$(date +%s)
# 计算剩余天数
remaining_days=$(( ($end_timestamp - $current_timestamp) / 86400 ))
# 打印证书有效期信息
echo "域名: $url 起始日期: $start_date 结束日期: $end_date 剩余天数: $remaining_days"
done
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。