lab 7 openbao
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-11-23 14:39:13 +03:00
parent 20afc2c790
commit 912a874f00
118 changed files with 12464 additions and 5108 deletions
+30 -30
View File
@@ -1,30 +1,30 @@
#!/usr/bin/env python3
"""Public lab7 external TLS check. Internal mTLS/policies require student tests."""
import ssl
import urllib.error
import urllib.request
from client import Client, LAB, NoRedirect, arguments, check, run
def main():
args = arguments('Lab7 external TLS trust check; provide --ca-file for the positive probe')
check(LAB==7,'this check belongs to lab7')
c = Client(args.base_url,args.ca_file)
c.call('GET','/health/ready',schema='Health')
# An empty trust store deliberately trusts no CA, including public CAs.
untrusted = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
untrusted.verify_mode = ssl.CERT_REQUIRED
untrusted.check_hostname = True
opener = urllib.request.build_opener(NoRedirect(),urllib.request.HTTPSHandler(context=untrusted))
rejected = False
try:
with opener.open(c.base+'/health/ready',timeout=5) as response:
response.read(1024)
except urllib.error.URLError as exc:
check(isinstance(exc.reason,ssl.SSLCertVerificationError),'negative probe failed for a non-certificate reason')
rejected = True
check(rejected,'server unexpectedly passed validation with an empty trust store')
print('PASS: trusted HTTPS works; untrusted CA rejected. This does NOT verify internal mTLS, OpenBao or hardening.')
if __name__=='__main__':
run(main)
#!/usr/bin/env python3
"""Public lab7 external TLS check. Internal mTLS/policies require student tests."""
import ssl
import urllib.error
import urllib.request
from client import Client, LAB, NoRedirect, arguments, check, run
def main():
args = arguments('Lab7 external TLS trust check; provide --ca-file for the positive probe')
check(LAB==7,'this check belongs to lab7')
c = Client(args.base_url,args.ca_file)
c.call('GET','/health/ready',schema='Health')
# An empty trust store deliberately trusts no CA, including public CAs.
untrusted = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
untrusted.verify_mode = ssl.CERT_REQUIRED
untrusted.check_hostname = True
opener = urllib.request.build_opener(NoRedirect(),urllib.request.HTTPSHandler(context=untrusted))
rejected = False
try:
with opener.open(c.base+'/health/ready',timeout=5) as response:
response.read(1024)
except urllib.error.URLError as exc:
check(isinstance(exc.reason,ssl.SSLCertVerificationError),'negative probe failed for a non-certificate reason')
rejected = True
check(rejected,'server unexpectedly passed validation with an empty trust store')
print('PASS: trusted HTTPS works; untrusted CA rejected. This does NOT verify internal mTLS, OpenBao or hardening.')
if __name__=='__main__':
run(main)