forked from mtusi2026/mtusi2026lab7
all for 3
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
"""Check generated identities and explicit trust boundaries without a running stack."""
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
ca=root/'.local/ca.crt'
|
||||
def verify(role,host,allowed=True):
|
||||
cert=root/'.local/id'/role/'cert.pem'
|
||||
p=subprocess.run(['openssl','verify','-CAfile',str(ca),'-verify_hostname',host,str(cert)],capture_output=True)
|
||||
if (p.returncode==0)!=allowed:
|
||||
raise SystemExit(f'Unexpected certificate result for {role} / {host}')
|
||||
for d in sorted((root/'.local/id').iterdir()):
|
||||
if d.name!='foreign':
|
||||
verify(d.name,d.name)
|
||||
verify('lb','localhost')
|
||||
verify('openbao','localhost')
|
||||
verify('grafana','localhost')
|
||||
verify('lb','wrong.invalid',False)
|
||||
verify('foreign','lb',False)
|
||||
print('PASS: generated service SANs, local ingress/admin hostnames, foreign issuer and hostname mismatch')
|
||||
Reference in New Issue
Block a user