fix(security): scope row locks and add explicit expiry recovery

This commit is contained in:
2026-11-20 19:51:42 +03:00
parent 93e5a915d5
commit 5c91f605fb
12 changed files with 193 additions and 26 deletions
+10 -5
View File
@@ -11,6 +11,7 @@ from pathlib import Path
from urllib.parse import quote
from cryptography import x509
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.x509.oid import ExtendedKeyUsageOID, NameOID
@@ -278,11 +279,15 @@ def generate():
).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
wrong_issuer = False
if (directory / "cert.pem").exists():
existing = x509.load_pem_x509_certificate(
(directory / "cert.pem").read_bytes()
)
try:
existing.verify_directly_issued_by(cert)
except (ValueError, InvalidSignature):
wrong_issuer = True
# Only this explicit operator command has the offline CA. Agents
# cannot refresh a bootstrap credential by themselves after expiry.
if (