mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
tests - fix wrong tls CN for staging tests
This commit is contained in:
parent
2bccb5d40e
commit
8800b58bbc
1 changed files with 6 additions and 1 deletions
|
|
@ -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']}"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue