說明:
1、測試了阿里和又拍雲的,雖然有某域名的證書了,但是輸出結果卻不是購買的證書信息,所以,如果有做cdn,則加host進行檢測的,沒有就無所謂了。
又拍雲cdn測試信息
Validity Not Before: Nov 14 00:00:00 2016 GMT Not After : Dec 12 23:59:59 2017 GMT Subject: C=CN, ST=zhejiang, L=hangzhou, O=Hangzhou Weiju Network Ltd., OU=\xE6\x8A\x80\xE6\x9C\xAF\xE9\x83\xA8, CN=*.upaiyun.com |
2、這裏只是單域名檢測,多域名,可以加上for循環。
3、提醒方式,自由發揮。
Shell
#!/bin/bash domain_name="statics.perofu.com" grep -q "${host}" /etc/hosts || echo "${host}" >> /etc/hosts
ssl_date=$(echo |openssl s_client -connect ${domain_name}:${ssl_port} 2>&1 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'|openssl x509 -text) echo "${ssl_date}" | grep 'Subject: CN' | grep -q "${domain_name}" else |
shell輸出結果
The [statics.perofu.com] out of date is : 2018-05-10 23:59:59 && [343] |