惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Hacker News
The Hacker News
C
Cyber Attacks, Cyber Crime and Cyber Security
A
Arctic Wolf
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Troy Hunt's Blog
小众软件
小众软件
L
LangChain Blog
Schneier on Security
Schneier on Security
D
DataBreaches.Net
爱范儿
爱范儿
P
Proofpoint News Feed
博客园 - 聂微东
M
MIT News - Artificial intelligence
Hacker News: Ask HN
Hacker News: Ask HN
T
Tailwind CSS Blog
Vercel News
Vercel News
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
T
Threat Research - Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
月光博客
月光博客
Spread Privacy
Spread Privacy
C
Cisco Blogs
S
Securelist
量子位
S
Security @ Cisco Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tenable Blog
WordPress大学
WordPress大学
T
The Exploit Database - CXSecurity.com
宝玉的分享
宝玉的分享
C
Cybersecurity and Infrastructure Security Agency CISA
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
MongoDB | Blog
MongoDB | Blog
C
CERT Recently Published Vulnerability Notes
Help Net Security
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
B
Blog RSS Feed
博客园_首页
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org

博客园 - Caraxes

共享打印机的另一种方式 简易防火墙映射测试 手动部署MySQL Exporter实战 Windows屏幕字体锯齿化的调整 Windows轻量级WebDAV服务器搭建 解决一个mysql数据库连接打开慢的问题记录 Mysql 赋予用户访问单表SELECT权限 UNIX换行和DOS换行的批量转换 Centos Mysql 8.0.43安装 关闭windows 更新驱动程序的方法 CentOS7下OpenSSH10.0p2升级实践 特殊符号的输入 tomcat启动一次问题的处理。 如何禁用键盘左侧Win键 Windows设置分页文件到D盘无效的解决方法 npm中文站的映射 使用ffmpeg批量生成视频的缩略图 解决内网HTTP由NG转发HTTPS后,部分跳转还是HTTP的问题 Linux LVM方式管理磁盘 Vscode Debug乱码的问题修复 一个切换不同JAVA版本的方法 ffmpeg提取音频 GO应用WINDOWS下添加程序图标 Linux 证书文件查看参考 Linux系统下安装Java环境 修改Jar包里面的配置文件
批量查看HTTPS的SSL证书的有效期脚本
Caraxes · 2025-03-05 · via 博客园 - Caraxes

因为管理的网站有点多,需要批量查看所有站点的SSL证书过期时间。
在任意一个创建一个检查的脚本,如:check.sh

check.sh内容如下
echo "快速检查全部的SSL证书过期时间"
urlArray=( \
"www.jd.com:443" \
"www.baidu.com:443" \
"www.bing.com:443" \
);

# 定义颜色变量
RED='\e[1;31m'
GREEN='\e[1;32m'
YELLOW='\e[1;33m'
BLUE='\e[1;34m'
NC='\e[0m' # No Color (重置颜色)

for url in ${urlArray[@]};
do
	printf "%-30s " $url
	expiry_date=$(echo | openssl s_client -connect $url 2>/dev/null | openssl x509 -noout -enddate 2>/dev/null | cut -d= -f2 | xargs -I {} date -d {} "+%Y-%m-%d")
	if [ "${#expiry_date}" -eq 10 ]; then
		expiry_timestamp=$(date -d "$expiry_date" +%s)
		current_timestamp=$(date +%s)
		diff_seconds=$((expiry_timestamp - current_timestamp))
		diff_days=$((diff_seconds / 86400))
		printf "证书过期日期: $expiry_date 08:00 (UTC+8)"
		if [[ "$diff_days" -lt 30 ]]; then
			printf " 剩余: ${RED}%4s天${NC}\n" $diff_days
		else
			printf " 剩余: %4s天\n" $diff_days
		fi
	else
		echo "获取证书过期日期失败"
	fi
done;

设置运行权限
chmod +x check.sh

说明:

  • 站点可以根据需要自行添加