openssl shell 检验 ssl 证书过期时间

语法如下

echo | openssl s_client -servername www.youqiantu.com -connect www.youqiantu.com:443 2>/dev/null | openssl x509 -noout -dates

添加很多域名的 check

#!/bin/bash

domains='
sentry.google.com
console.google.com
www.google.com
m.google.com
api.google.com
'

for domain in $domains
do
  check_result=$(echo | openssl s_client -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -noout -dates | grep After)
  echo "$domain\t $check_result" | awk -F"\t" '{sub(/^ /,"",$2);printf "%-40s%s\n",$1,$2}'
done

发表评论

电子邮件地址不会被公开。 必填项已用*标注