citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

cert (435B)


      1 #! /usr/bin/env nix-shell
      2 #! nix-shell -i bash -p openssl
      3 out=$(echo "Q" | openssl s_client -connect "${2:-$1}":"${3:-443}" -servername "$1")
      4 
      5 cert=$(sed -ne '
      6    /-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p      # got the range, ok
      7    /-END CERTIFICATE-/q                            # bailing out soon as the cert end seen
      8 ' <<<"$out")
      9 
     10 (
     11 echo "$cert" | openssl x509 -fingerprint -sha1 -in - -text -noout
     12 
     13 printf "%s\n" "$out"
     14 ) | less