~mikini/hometools

hometools/cert_dump.sh -rwxr-xr-x 504 bytes
158a6504 — Mikkel Kirkgaard Nielsen Exit on network error & indicate date of rate used a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /bin/bash

#COMMAND=full
#COMMAND=subject
COMMAND=bundle
shopt -s nullglob

for c in ${1:-*.crt *.cer}; do
  echo "Dumping \"$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