Created
July 16, 2018 03:07
-
-
Save koshatul/b36ff4c9040f21545b8755ea04aaa227 to your computer and use it in GitHub Desktop.
SSL CA bundle split and openssl on each certificate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set +e | |
CA_BUNDLE="${1}" | |
shift | |
if [ ! -s "${CA_BUNDLE}" ]; then | |
echo "usage: ${0} <ca bundle file> [openssl commands]" | |
echo "example: ${0} ca-bundle.pem -noout -subject -issuer" | |
exit 2 | |
fi | |
TMP_DIR=$(mktemp -d) | |
csplit -k -f "${TMP_DIR}/cert" "${CA_BUNDLE}" '/END CERTIFICATE/+1' {100} >/dev/null 2>/dev/null | |
for I in ${TMP_DIR}/cert*; do | |
if [ -s "${I}" ]; then | |
echo "####################################################################" | |
openssl x509 -in "${I}" "${@}" | |
fi | |
done | |
rm -r -f "${TMP_DIR}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: