1 Star 0 Fork 0

yll1024335892 / shell_script

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
http_detection.sh 809 Bytes
一键复制 编辑 原始数据 按行查看 历史
yll1024335892 提交于 2023-12-13 11:45 . https的信息获取
#/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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/1024335892/shell_script.git
git@gitee.com:1024335892/shell_script.git
1024335892
shell_script
shell_script
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891