From 5cb294ac67be9071ced9375930f646fac893bcbd Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 3 Nov 2025 14:00:15 -0500 Subject: [PATCH] update CA expiration time In 1bb23182b8330e50cb the galera certs were regenerated with a three year expiry, but this did not include the CA expiration time, leading to failures again. this change updates that time as well and adds a script that can be used to regen the values. --- config/samples/cert-manager-galera-cert.yaml | 3 +- tests/chainsaw/common/regenerate-tls-certs.sh | 75 +++++++++++++++++++ tests/chainsaw/common/tls-certificate.yaml | 15 +++- .../02-tls-certificate.yaml | 43 ++--------- .../galera_deploy_tls/01-tls-certificate.yaml | 43 ++--------- 5 files changed, 103 insertions(+), 76 deletions(-) create mode 100755 tests/chainsaw/common/regenerate-tls-certs.sh diff --git a/config/samples/cert-manager-galera-cert.yaml b/config/samples/cert-manager-galera-cert.yaml index 0982b9a9..deaa4728 100644 --- a/config/samples/cert-manager-galera-cert.yaml +++ b/config/samples/cert-manager-galera-cert.yaml @@ -16,6 +16,7 @@ spec: isCA: true commonName: my-selfsigned-ca secretName: root-secret + duration: 32088h privateKey: algorithm: ECDSA size: 256 @@ -47,7 +48,7 @@ spec: secretTemplate: labels: mariadb-ref: openstack - duration: 6h + duration: 32088h renewBefore: 1h subject: organizations: diff --git a/tests/chainsaw/common/regenerate-tls-certs.sh b/tests/chainsaw/common/regenerate-tls-certs.sh new file mode 100755 index 00000000..481280c8 --- /dev/null +++ b/tests/chainsaw/common/regenerate-tls-certs.sh @@ -0,0 +1,75 @@ +#!/bin/bash +set -e + +echo "This script will regenerate the TLS certificates in tls-certificate.yaml" +echo "Prerequisites:" +echo " - oc configured with an OpenShift cluster" +echo " - cert-manager installed in the cluster" +echo " - openstack namespace/project exists" +echo "" + +# Extract the commented cert-manager resources +TEMP_FILE=$(mktemp) +sed -n '5,69s/^# //p' tls-certificate.yaml > "$TEMP_FILE" + +echo "Extracted cert-manager resources to $TEMP_FILE" +echo "" +echo "Deleting any existing secrets..." +oc delete secret root-secret galera-cert -n openstack --ignore-not-found=true + +echo "" +echo "Applying cert-manager resources..." + +# Apply the resources +oc apply -f "$TEMP_FILE" + +echo "Waiting for certificates to be ready..." +echo " - Waiting for root-secret (CA certificate)..." +oc wait --for=condition=ready certificate/selfsigned-ca -n openstack --timeout=60s + +echo " - Waiting for galera-cert certificate..." +oc wait --for=condition=ready certificate/galera-cert -n openstack --timeout=60s + +echo "" +echo "Certificates are ready! Extracting secret data..." + +# Get the secret data +CA_CRT=$(oc get secret root-secret -n openstack -o jsonpath='{.data.ca\.crt}') +TLS_CRT=$(oc get secret galera-cert -n openstack -o jsonpath='{.data.tls\.crt}') +TLS_KEY=$(oc get secret galera-cert -n openstack -o jsonpath='{.data.tls\.key}') + +echo "" +echo "Certificate validity periods:" +echo " CA Certificate:" +echo "$CA_CRT" | base64 -d | openssl x509 -noout -dates | sed 's/^/ /' +echo "" +echo " Galera Certificate:" +echo "$TLS_CRT" | base64 -d | openssl x509 -noout -dates | sed 's/^/ /' +echo "" + +echo "" +echo "Creating new hardcoded secret..." +echo "---" +cat <