Skip to content
Merged
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
23 changes: 18 additions & 5 deletions tests/kuttl/common/osp_check_cert_issuer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ function check_keystone_endpoint {
fi
}

get_issuer_cn() {
local host_port="$1"
local output

output=$(openssl s_client -connect "$host_port" </dev/null 2>/dev/null |
openssl x509 -noout -issuer 2>/dev/null)

echo "$output" | sed -n 's/^.*CN[[:space:]]*=[[:space:]]*\([^,]*\).*$/\1/p'
}

keystone_url=$(openstack endpoint list -c URL -f value | grep 'keystone-public')
keystone_host_port=$(extract_host_port "$keystone_url")

Expand All @@ -60,11 +70,14 @@ for url in $(openstack endpoint list -c URL -f value | grep "$endpoint_filter");
host_port=$(extract_host_port "$url")

echo "Checking $host_port ..."
if [[ "$ENDPOINT_TYPE" == "public" ]]; then
ISSUER=$(echo | openssl s_client -connect "$host_port" 2>/dev/null | openssl x509 -noout -issuer | sed -n 's/^.*CN=\([^,]*\).*$/\1/p' | sed 's/ //g')
else
ISSUER=$(openssl s_client -connect $host_port </dev/null 2>/dev/null | openssl x509 -issuer -noout -in /dev/stdin | sed 's/ //g')
fi
for retry in {1..5}; do
echo "Retrying $retry on getting issuer $host_port..."
ISSUER=$(get_issuer_cn "$host_port")
if [[ -n "$ISSUER" ]]; then
break
fi
sleep 20
done

if [[ "$ISSUER" != "$EXPECTED_ISSUER" ]]; then
ISSUER_MISMATCHES+="$host_port issued by $ISSUER, expected $EXPECTED_ISSUER\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ commands:

- script: |
echo "Checking issuer of internal certificates..."
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "issuer=CN=rootca-internal-custom" "internal"
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "rootca-internal-custom" "internal"

- script: |
echo "Checking issuer of ingress certificates..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ commands:

- script: |
echo "Checking issuer of internal certificates..."
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "issuer=CN=rootca-internal" "internal"
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "rootca-internal" "internal"

- script: |
echo "Checking issuer of ingress certificates..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ commands:

- script: |
echo "Checking issuer of internal certificates..."
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "issuer=CN=rootca-internal" "internal"
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "rootca-internal" "internal"

- script: |
echo "Checking issuer of ingress certificates..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ commands:

- script: |
echo "Checking issuer of internal certificates..."
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "issuer=CN=rootca-internal-custom" "internal"
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "rootca-internal-custom" "internal"

- script: |
echo "Checking issuer of ingress certificates..."
Expand Down