Skip to content

Commit f20c7d4

Browse files
authored
Update auto-update-certs.sh
1 parent a50cb5d commit f20c7d4

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

scripts/auto-update-certs.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,39 @@ fi
9494
log "Applying certificates to /persistent/pki/custom via cert-setup.sh (as root)"
9595
docker compose exec -T -u root ziti-controller bash /scripts/cert-setup.sh >/dev/null
9696

97+
# Sync certificates into the controller paths that are actually referenced
98+
# by /persistent/ziti-controller.yaml. Without this, controller may keep using
99+
# the old cert/key even though /persistent/pki/custom was updated successfully.
100+
log "Syncing certificates into active controller PKI paths"
101+
docker compose exec -u 0 ziti-controller sh -lc '
102+
set -e
103+
104+
# Main controller identity paths
105+
CTRL_CERT_DIR="/persistent/pki/ziti.legenda-group.ru-intermediate/certs"
106+
CTRL_KEY_DIR="/persistent/pki/ziti.legenda-group.ru-intermediate/keys"
107+
CTRL_CERT="$CTRL_CERT_DIR/ziti.legenda-group.ru-server.chain.pem"
108+
CTRL_KEY="$CTRL_KEY_DIR/ziti.legenda-group.ru-server.key"
109+
110+
# Edge API / web identity paths
111+
EDGE_CERT_DIR="/persistent/pki/ziti-edge-controller-intermediate/certs"
112+
EDGE_KEY_DIR="/persistent/pki/ziti-edge-controller-intermediate/keys"
113+
EDGE_CERT="$EDGE_CERT_DIR/ziti.legenda-group.ru-server.chain.pem"
114+
EDGE_KEY="$EDGE_KEY_DIR/ziti.legenda-group.ru-server.key"
115+
116+
mkdir -p "$CTRL_CERT_DIR" "$CTRL_KEY_DIR" "$EDGE_CERT_DIR" "$EDGE_KEY_DIR"
117+
118+
# Copy the active server certificate and private key into all referenced paths
119+
cp /persistent/pki/custom/certs/server-cert.pem "$CTRL_CERT"
120+
cp /persistent/pki/custom/keys/server-key.pem "$CTRL_KEY"
121+
cp /persistent/pki/custom/certs/server-cert.pem "$EDGE_CERT"
122+
cp /persistent/pki/custom/keys/server-key.pem "$EDGE_KEY"
123+
124+
chmod 644 "$CTRL_CERT" "$EDGE_CERT"
125+
chmod 600 "$CTRL_KEY" "$EDGE_KEY"
126+
127+
echo "Synced controller certs:"
128+
ls -l "$CTRL_CERT" "$CTRL_KEY" "$EDGE_CERT" "$EDGE_KEY"
129+
'
97130
log "Restarting controller"
98131
docker compose restart ziti-controller >/dev/null
99132

0 commit comments

Comments
 (0)