Skip to content

Instantly share code, notes, and snippets.

@ntulip
Forked from joshenders/certchain.sh
Created January 18, 2016 18:18
Show Gist options
  • Save ntulip/d17cc233c7cddb621aef to your computer and use it in GitHub Desktop.
Save ntulip/d17cc233c7cddb621aef to your computer and use it in GitHub Desktop.

Revisions

  1. @joshenders joshenders revised this gist Jan 18, 2016. No changes.
  2. @joshenders joshenders revised this gist Jan 18, 2016. No changes.
  3. @joshenders joshenders revised this gist Jan 18, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions certchain.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    function certchain() {
    # Usage: certchain
    # Display PKI chain-of-trust for a given domain
    # GistID: https://gist.github.com/joshenders/cda916797665de69ebcd
    if [[ "$#" -ne 1 ]]; then
    echo "Usage: ${FUNCNAME} <ip|domain[:port]>"
    return 1
  4. @joshenders joshenders created this gist Jan 18, 2016.
    18 changes: 18 additions & 0 deletions certchain.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    function certchain() {
    # Usage: certchain
    # Display PKI chain-of-trust for a given domain
    if [[ "$#" -ne 1 ]]; then
    echo "Usage: ${FUNCNAME} <ip|domain[:port]>"
    return 1
    fi

    local host_port="$1"

    if [[ "$1" != *:* ]]; then
    local host_port="${1}:443"
    fi

    openssl \
    s_client -connect "${host_port}" </dev/null 2>/dev/null \
    | fgrep -E '\ (s|i):'
    }