feat(security): add operator rotation and recovery commands

This commit is contained in:
2026-11-20 19:02:00 +03:00
parent 1dd020d060
commit f2ea9d65a8
22 changed files with 983 additions and 46 deletions
+21 -1
View File
@@ -270,7 +270,27 @@ def generate():
).not_valid_after_utc
< datetime.now(UTC) + timedelta(hours=1)
)
if not (directory / "key.pem").exists() or renew_operator:
renew_bootstrap = (
role != "operator"
and (directory / "cert.pem").exists()
and x509.load_pem_x509_certificate(
(directory / "cert.pem").read_bytes()
).not_valid_after_utc
< datetime.now(UTC) + timedelta(minutes=5)
)
wrong_issuer = (
directory / "cert.pem"
).exists() and x509.load_pem_x509_certificate(
(directory / "cert.pem").read_bytes()
).issuer != cert.subject
# Only this explicit operator command has the offline CA. Agents
# cannot refresh a bootstrap credential by themselves after expiry.
if (
not (directory / "key.pem").exists()
or renew_operator
or renew_bootstrap
or wrong_issuer
):
leaf_key, leaf = sign_leaf(
key,
cert,