Created
March 11, 2017 17:57
-
-
Save Programie/374d2c9e2983a1f99e070c00d7197238 to your computer and use it in GitHub Desktop.
Find the right issuing CA certificate for the given certificate (based on the subject) and symlink it to the specific target file.
This file contains 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 | |
CERT_FILE="$1" | |
CA_FILE="$2" | |
CA_DIR="$3" | |
ISSUER=$(openssl x509 -in ${CERT_FILE} -noout -issuer | sed "s/^issuer= //g") | |
for PEM in ${CA_DIR}/*; do | |
SUBJECT=$(openssl x509 -in ${PEM} -noout -subject | sed "s/^subject= //g") | |
if [ "$ISSUER" = "$SUBJECT" ]; then | |
ln -sf ${PEM} ${CA_FILE} | |
exit | |
fi | |
done | |
echo "Unable to find right issuer certificate for certificate (issuer = $ISSUER)" >&2 | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment