forked from mtusi2026/mtusi2026lab7
fix(security): scope row locks and add explicit expiry recovery
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user