How to determine SSL cert expiration date from a PEM encoded certificate?

前端 未结 9 2107
感动是毒
感动是毒 2020-11-30 16:21

If I have the actual file and a Bash shell in Mac or Linux, how can I query the cert file for when it will expire? Not a web site, but actually the certificate file itself,

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 16:49

    One line checking on true/false if cert of domain will be expired in some time later(ex. 15 days):

    openssl x509 -checkend $(( 24*3600*15 )) -noout -in <(openssl s_client -showcerts -connect my.domain.com:443 /dev/null | openssl x509 -outform PEM)
    if [ $? -eq 0 ]; then
      echo 'good'
    else
      echo 'bad'
    fi
    

提交回复
热议问题