Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions mgradm/shared/podman/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,28 @@ func parseClientTrustResults(saltOutput []byte, unreachable map[string]bool) (
// CA file holds a certificate matching a given SHA-256 fingerprint.
// It prints "OK" on a match and "MISSING" otherwise.
const clientTrustCheckScript = `
caFile="/etc/pki/trust/anchors/RHN-ORG-TRUSTED-SSL-CERT"
found=MISSING

# Without the managed CA file the minion cannot trust the new CA yet.
[ -f "$caFile" ] || { echo MISSING; exit 0; }
for caFile in \
/etc/pki/trust/anchors/RHN-ORG-TRUSTED-SSL-CERT \
/etc/pki/ca-trust/source/anchors/RHN-ORG-TRUSTED-SSL-CERT \
/usr/local/share/ca-certificates/RHN-ORG-TRUSTED-SSL-CERT.crt; do
# Skip the locations that do not apply to this minion's OS.
[ -f "$caFile" ] || continue

# Split the (possibly multi-cert) CA file into one file per certificate.
d=$(mktemp -d)
trap 'rm -rf "$d"' EXIT
csplit -z -s -f "$d/cert-" "$caFile" '/-----BEGIN CERTIFICATE-----/' '{*}' 2>/dev/null
# Split the (possibly multi-cert) CA file into one file per certificate.
d=$(mktemp -d)
csplit -z -s -f "$d/cert-" "$caFile" '/-----BEGIN CERTIFICATE-----/' '{*}' 2>/dev/null

# Report OK as soon as one of the certificates matches the expected fingerprint.
found=MISSING
for cert in "$d"/cert-*; do
fp=$(openssl x509 -in "$cert" -noout -fingerprint -sha256 2>/dev/null | cut -d= -f2)
[ "$fp" = "%[1]s" ] && found=OK
# Report OK as soon as one of the certificates matches the expected fingerprint.
for cert in "$d"/cert-*; do
fp=$(openssl x509 -in "$cert" -noout -fingerprint -sha256 2>/dev/null | cut -d= -f2)
[ "$fp" = "%[1]s" ] && found=OK
done

rm -rf "$d"
done

echo "$found"
`

Expand Down
1 change: 1 addition & 0 deletions uyuni-tools.changes.mfriedrich.fix-ca-rotation-nonsuse
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Check all supported locations for CA file in rotation check script
Loading