Skip to content

Commit

Permalink
blueprint: fix CA cert testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap committed Dec 13, 2024
1 parent 3ee2524 commit 994201a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion test/config-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"fedora*"
],
"image-types": [
"qcow2"
"ami"
]
},
"./configs/all-with-fips.json": {
Expand Down
15 changes: 9 additions & 6 deletions test/scripts/base-host-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,20 @@ get_oscap_score() {
}

check_ca_cert() {
serial=$(jq -r '.blueprint.customizations.cacerts.pem_certs[0]' "${config}" | openssl x509 -noout -serial | cut -d= -f 2-)
serial=$(jq -r '.blueprint.customizations.cacerts.pem_certs[0]' "${config}" | openssl x509 -noout -serial | cut -d= -f 2- | tr '[:upper:]' '[:lower:]')
cn=$(jq -r '.blueprint.customizations.cacerts.pem_certs[0]' "${config}" | openssl x509 -noout -subject | sed -E 's/.*CN ?= ?//')

echo "πŸ“— Checking CA cert anchor file"
echo "πŸ“— Checking CA cert anchor file serial '${serial}'"
if ! [ -e "/etc/pki/ca-trust/source/anchors/${serial}.pem" ]; then
echo "Anchor CA file does not exist"
echo "Anchor CA file does not exist, directory contents:"
find /etc/pki/ca-trust/source/anchors
exit 1
fi

echo "πŸ“— Checking extracted CA cert file"
if ! [ -e "/etc/pki/ca-trust/source/extracted/pem/directory-hash/Test_CA_for_osbuild.pem.pem" ]; then
echo "Extracted CA file does not exist"
echo "πŸ“— Checking extracted CA cert file named '${cn}'"
if ! grep -q "${cn}" /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem; then
echo "Extracted CA cert not found in the bundle, tls-ca-bundle.pem contents:"
grep '^#' /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
exit 1
fi
}
Expand Down

0 comments on commit 994201a

Please sign in to comment.