]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
pytests: import test_tls_cert_hostname_mismatch (test16)
authorTomas Krizek <tomas.krizek@nic.cz>
Thu, 15 Nov 2018 16:52:00 +0000 (17:52 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 4 Dec 2018 16:13:42 +0000 (17:13 +0100)
tests/pytests/test_tls_certs.py

index 18d7d9477186e280af8b922421cb9f618cf7e37e..8c4f455d1f4e2c958b877d9aeae75b74e89710cf 100644 (file)
@@ -1,5 +1,9 @@
 """Tests with TLS certificates"""
 
+import ssl
+
+import pytest
+
 import utils
 
 
@@ -19,3 +23,12 @@ def test_tls_selfsigned_cert(kresd_tt, sock_family):
     ssock.connect(dest)
 
     utils.ping_alive(ssock)
+
+
+def test_tls_cert_hostname_mismatch(kresd_tt, sock_family):
+    sock, dest = kresd_tt.stream_socket(sock_family, tls=True)
+    ctx = utils.make_ssl_context(verify_location=kresd_tt.tls_cert_path)
+    ssock = ctx.wrap_socket(sock, server_hostname='wrong-host-name')
+
+    with pytest.raises(ssl.CertificateError):
+        ssock.connect(dest)