Skip to content

Commit 8db46c7

Browse files
lablansMartin Lablans
authored andcommitted
Fix CI/CD: Reuse existing proxy key when re-enrolling in dev PKI
1 parent 462bc0d commit 8db46c7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

dev/pki/pki

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,15 @@ function request() {
9595
application=$1
9696
cn=$2
9797
ttl=$3
98-
openssl req -new -newkey rsa:2048 -nodes -keyout ${application}.priv.pem -out ${application}.csr -subj "/CN=${cn}" 2>/dev/null
98+
# Beam only supports multiple certificates per proxy when they share one key.
99+
# devsetup enrolls some proxies repeatedly to create duplicate certs, so reuse
100+
# an existing key on re-enrollment and generate a fresh one only the first time;
101+
# otherwise senders may encrypt to a key the proxy no longer holds.
102+
if [ -s "${application}.priv.pem" ] && openssl pkey -in "${application}.priv.pem" -noout 2>/dev/null; then
103+
openssl req -new -key "${application}.priv.pem" -out ${application}.csr -subj "/CN=${cn}" 2>/dev/null
104+
else
105+
openssl req -new -newkey rsa:2048 -nodes -keyout ${application}.priv.pem -out ${application}.csr -subj "/CN=${cn}" 2>/dev/null
106+
fi
99107
data=$(jq -Rs '{common_name: "'$cn'", ttl: "'$ttl'", csr: .}' < ${application}.csr)
100108
echo "Creating Certificate for domain $cn"
101109
curl --header "X-Vault-Token: $VAULT_TOKEN" \

0 commit comments

Comments
 (0)