check a certificate

See a site's TLS certificate, when it expires and who issued it, or the same for a .pem file.

  • security
  • network

Steps

  1. openssl s_client -connect example.com:443 -servername example.com < /dev/null | openssl x509 -noout -dates -subject -issuer

    a site's certificate: dates, name, issuer

  2. openssl x509 -in cert.pem -noout -enddate

    when a certificate file expires

  3. openssl x509 -in cert.pem -noout -text

    everything in it

  4. openssl x509 -in cert.pem -noout -checkend 2592000

    does it expire within 30 days? (exit 1 if so)

  5. curl -vI https://example.com 2>&1 | grep -E 'expire|issuer'

    the same, the quick way

Commands used

  • openssl
  • curl

Each has a page in lore: lore openssl opens it.