~mikini/hometools

fefd2faefba36e00f83be212fb11a1de9bfdd940 — Mikkel Kirkgaard Nielsen 1 year, 1 month ago d46adb3
cert_dump.sh: glob more suffixes, handle bundles
1 files changed, 13 insertions(+), 4 deletions(-)

M cert_dump.sh
M cert_dump.sh => cert_dump.sh +13 -4
@@ 1,10 1,19 @@
#! /bin/bash

#subject
#for c in ${2:-*.crt}; do echo $c; openssl x509 -text -in $c | grep ${2:-Subject}: ; done
#COMMAND=full
#COMMAND=subject
COMMAND=bundle
shopt -s nullglob

# full
for c in ${1:-*.crt *.cer}; do
  echo "Dumping \"$c\""
  openssl x509 -text -in "$c"

  # full
  [ $COMMAND == full ] && openssl x509 -text -in "$c"
  # subject
  [ $COMMAND == subject ] && openssl x509 -text -in "$c" | grep Subject:
  # bundle
  # see https://serverfault.com/questions/590870/how-to-view-all-ssl-certificates-in-a-bundle
  [ $COMMAND == bundle ] && openssl crl2pkcs7 -nocrl -certfile "$c" | openssl pkcs7 -print_certs -text -noout
done