Skip to content

containeroo/certinfo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

certinfo

Get information about the certificate from one or more hostnames.

Usage

Usage:
  certinfo HOSTNAME [HOSTNAME ...] [flags]
Flags:
        --timeout TIMEOUT          Dial timeout (Default: 5s)
        --retry RETRY              Retry attempts for TCP connect (Default: 2)
        --output <text|json|none>  Output format: (Default: text)
        --threshold THRESHOLD      Warn if cert expires within this duration (e.g. 720h) (Default: 0s)
        --proxy PROXY              Proxy URL (http[s]:// or socks5[h]://). Overrides env. [Group: proxy-choice (One Of)]
        --no-proxy                 Bypass all proxies. Overrides --proxy and env. [Group: proxy-choice (One Of)]
    -s, --silent                   Suppress normal output; only print expiration warnings
    -h, --help                     Show help
        --version                  Show version

Examples

get certificate for google.io

certinfo google.io

output:

Host: google.io:443
Certs:
    Issuer:     GTS CA 1C3 (Google Trust Services LLC)
    Subject:    *.google.io
    Not Before: Monday, 12 July 2021 at 07:24:53 (CEST)
    Not After:  Monday, 4 October 2021 at 07:24:52 (CEST)
    DNS names:  *.google.io google.io

get certificate from google.io and output the complete certificate information as json

certinfo --output json --verbose google.io

output:

2018/11/04 19:19:15 connecting to google.io:443
[
  {
    "Host": "google.io",
    "Port": 443,
    "Certs": [
      {
        // snip many fields!
      }
    ]
  }
]

get certificate for google.io and check if the certificate is valid for more than 30 days

certinfo --output none --threshold 30 google.io

output:

there is no output if the certificate expires more than 30 days

get certificate for google.io and check if the certificate is valid for more than 20 days

certinfo --output none --threshold 20 google.io

output:

Problem running certinfo: certificate for *.google.io expires in 60.10 days (at 2021-09-14T17:47:02Z)

get certificate for google.io and extract the expiration date

certinfo --output json example.io | jq -r '.[].Certs[].NotBefore'

output:

2021-06-22T17:47:03Z

using in a cronjob with healthchecks.io

0 2 * * * root result=$(certinfo google.io); curl -fsS -X POST --data-raw "$result" "https://healthchecks.example.com/ping/<UID>$([ $? != 0 ] && echo -n /fail)" > /dev/null

inspired by certinfo

About

Simple CLI tool to get information about a certificate

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages