tests - fix wrong tls CN for staging tests

This commit is contained in:
fl0ppy-d1sk 2024-01-09 11:26:28 +01:00
parent 2bccb5d40e
commit 8800b58bbc
No known key found for this signature in database
GPG key ID: 93EE47CC3D061500

View file

@ -142,15 +142,20 @@ class Test(ABC):
r = get(ex_url, timeout=10, verify=False)
ok = test["status"] == r.status_code
if ok and "tls" in test:
ex_tls = test["tls"]
for ex_domain, test_domain in self._domains.items():
if search(ex_domain, ex_tls):
ex_tls = sub(ex_domain, test_domain, ex_tls)
connection = create_connection((urlparse(ex_url).netloc, 443))
context = SSLContext()
sock = context.wrap_socket(connection, server_hostname=urlparse(ex_url).netloc)
cert = sock.getpeercert(True)
sock.close()
x509 = crypto.load_certificate(crypto.FILETYPE_ASN1, cert)
if x509.get_subject().CN != test["tls"]:
if x509.get_subject().CN != ex_tls:
ok = False
log("TEST", "⚠️", f"wrong cert CN : {x509.get_subject().CN}")
return ok
except:
return False
raise (Exception(f"unknown test type {test['type']}"))