Skip to content

Instantly share code, notes, and snippets.

@stigtsp
Created May 8, 2023 12:44
Show Gist options
  • Save stigtsp/26d687453c776ce39f8a25dc45c7b111 to your computer and use it in GitHub Desktop.
Save stigtsp/26d687453c776ce39f8a25dc45c7b111 to your computer and use it in GitHub Desktop.
shell script to compare cacert files
#!/usr/bin/env bash
set -eu
parse_bundle() {
# https://serverfault.com/questions/590870/how-to-view-all-ssl-certificates-in-a-bundle
openssl crl2pkcs7 -nocrl -certfile $1 | openssl pkcs7 -print_certs
}
echo "Comparing certs in $1 and $2" >&2
tmpdir=$(mktemp -d)
parse_bundle $1 > $tmpdir/a
parse_bundle $2 > $tmpdir/b
pushd $tmpdir
echo "Comparing output in $tmpdir" >&2
diff -u a b
popd
trap "rm -vr $tmpdir" EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment