Implement lab 7 security and mTLS
Skeleton contracts / contracts (pull_request) Blocked by required conditions

This commit is contained in:
2026-11-26 16:55:53 +03:00
parent 20afc2c790
commit ab7b467957
54 changed files with 3240 additions and 25 deletions
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
set -eu
# Rotation is deliberately operator-driven: no root token is stored in the repo.
CERT_DIR=${CERT_DIR:-certs}
SERVICE=${1:-api1}
test -f "$CERT_DIR/ca.key" || { echo "CA key is missing" >&2; exit 2; }
umask 077
openssl genrsa -out "$CERT_DIR/$SERVICE-client.key.new" 2048
openssl req -new -key "$CERT_DIR/$SERVICE-client.key.new" -subj "/CN=$SERVICE" -out "$CERT_DIR/$SERVICE-client.csr.new"
printf 'extendedKeyUsage=clientAuth\n' > "$CERT_DIR/client.ext.new"
openssl x509 -req -in "$CERT_DIR/$SERVICE-client.csr.new" -CA "$CERT_DIR/ca.crt" -CAkey "$CERT_DIR/ca.key" -CAcreateserial -out "$CERT_DIR/$SERVICE-client.crt.new" -days 30 -sha256 -extfile "$CERT_DIR/client.ext.new"
mv "$CERT_DIR/$SERVICE-client.key.new" "$CERT_DIR/$SERVICE-client.key"
mv "$CERT_DIR/$SERVICE-client.crt.new" "$CERT_DIR/$SERVICE-client.crt"
rm -f "$CERT_DIR/$SERVICE-client.csr.new" "$CERT_DIR/client.ext.new" "$CERT_DIR/ca.srl"
echo "Rotated $SERVICE client certificate. Restart only that service and revoke the previous identity in the CA/OpenBao registry."