Lab7: HTTPS, mTLS, OpenBao, трек 2 PKI на оценку 5

This commit is contained in:
Wladislava1
2026-11-16 23:55:31 +03:00
commit 3676de91bf
122 changed files with 14006 additions and 0 deletions
+30
View File
@@ -0,0 +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)