"""Fresh CA/leaf bootstrap in temporary storage; never touches the real operator CA.""" import json,os,subprocess,tempfile from pathlib import Path import pki os.umask(0o077) with tempfile.TemporaryDirectory(prefix='lab7-pki-check-') as name: p=Path(name) subprocess.run(['openssl','req','-x509','-newkey','rsa:3072','-nodes','-days','30','-keyout',str(p/'ca.key'),'-out',str(p/'ca.crt'),'-subj','/CN=lab7-operator-ca','-addext','keyUsage=critical,keyCertSign,cRLSign','-addext','basicConstraints=critical,CA:TRUE'],check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL) pki.PRIVATE=p;pki.issue('probe') subprocess.run(['openssl','verify','-x509_strict','-purpose','sslserver','-CAfile',str(p/'ca.crt'),str(p/'roles/probe/service.crt')],check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL) print(json.dumps({'status':'PASS','fresh_CA_generated':True,'fresh_leaf_issued':True,'strict_x509_chain_and_server_purpose':True,'real_operator_CA_untouched':True},indent=2))