Files
mtusi2026lab7/scripts/prepare_probes.py
T

11 lines
776 B
Python

"""Negative fixtures keep the allowed CN, isolating CA/expiry from role checks."""
from pki import PRIVATE,issue
import subprocess,os
os.umask(0o077)
for role in ['api','worker','prometheus','grafana','collector','lb']:
issue(role,expired=True,destination='expired-'+role)
p=PRIVATE/'roles'/('foreign-'+role);p.mkdir(exist_ok=True)
subprocess.run(['openssl','req','-x509','-newkey','rsa:2048','-nodes','-days','2','-keyout',str(p/'service.key'),'-out',str(p/'service.crt'),'-subj','/CN='+role,'-addext','extendedKeyUsage=clientAuth'],check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
(p/'service.pem').write_bytes((p/'service.crt').read_bytes()+(p/'service.key').read_bytes())
print('Foreign/expired fixtures use the otherwise allowed identity')