golang 时间戳_使用 golang 内置模块实现网站TLS证书过期日期查询

由于前段时间出现过大公司域名证书未及时更新导致服务中断,之前也有了解过 golang。闲来无事,于是用了半天的时间,通过 golang 官网文档,写了一个小工具,来获取域名证书的到期时间。

ee71089f4ac64283f9f2c1ce92acb8f8.png

证书信息

通过传参 -d 域名 来获取本地时区的证书过期时间

➜  tls-cert-expire git:(master) ✗ ./tls-cert-expire -d www.io-notes.com2020-06-24 08:19:05 +0800 CST

通过参数 -s 可以获取过期日期的时间戳,方便其他脚本调用进行计算告警

➜  tls-cert-expire git:(master) ✗ ./tls-cert-expire -d www.io-notes.com -s1592957945

其他参数,默认超时为 5s ,https 端口为 443

➜  tls-cert-expire git:(master) ✗ ./tls-cert-expire -hUsage of ./tls-cert-expire:  -d domain        domain: 域名 IP  -p port        port : 端口 (default 443)  -s    seconds since 1970-01-01 00:00:00 UTC  -t timeout        timeout : 连接超时 (default 5)

时间戳转化工具: https://www.io-notes.com/tools/timestamp.html

编译好的二进制包下载地址: https://github.com/io-notes/tls-cert-expire/releases

源码: https://github.com/io-notes/tls-cert-expire/blob/master/tls-cert-expire.go

可对源码稍加修改,可获取更多证书信息。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值