Skip to content

Commit

Permalink
Merge pull request #1207 from openziti/put-verifyCert-back
Browse files Browse the repository at this point in the history
add a couple of useful functions back
  • Loading branch information
dovholuknf authored Jul 13, 2023
2 parents 3c5e767 + c1daaea commit 866d4c4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions quickstart/docker/image/ziti-cli-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1498,4 +1498,42 @@ function waitForController {
_wait_for_controller
}

function printUsage() {
echo "Usage: ${1-} [cert to test] [ca pool to use]"
}

function verifyCertAgainstPool() {
if [[ "" == "${1-}" ]]
then
printUsage "verifyCertAgainstPool"
return 1
fi

if [[ "" == "$2" ]]
then
printUsage "verifyCertAgainstPool"
return 1
fi

echo " Verifying that this certificate:"
echo " - ${1-}"
echo " is valid for this ca pool:"
echo " - $2"
echo ""
openssl verify -partial_chain -CAfile "$2" "${1-}"
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
echo ""
echo "============ SUCCESS! ============"
else
echo ""
echo "============ FAILED TO VALIDATE ============"
fi
}

function showIssuerAndSubjectForPEM() {
echo "Displaying Issuer and Subject for cert pool:"
echo " ${1-}"
openssl crl2pkcs7 -nocrl -certfile "${1-}" | openssl pkcs7 -print_certs -text -noout | grep -E "(Subject|Issuer)"
}
set +uo pipefail

0 comments on commit 866d4c4

Please sign in to comment.