@@ -39,22 +39,23 @@ class FailureHost:
39
39
error_messages : list [str ]
40
40
41
41
42
+ wrong_host_failure_host = FailureHost (
43
+ host = "wrong.host.badssl.com" ,
44
+ error_messages = [
45
+ # OpenSSL
46
+ "Hostname mismatch, certificate is not valid for 'wrong.host.badssl.com'" ,
47
+ # macOS
48
+ "certificate name does not match" ,
49
+ # macOS with revocation checks
50
+ "certificates do not meet pinning requirements" ,
51
+ # macOS 10.13
52
+ "Recoverable trust failure occurred" ,
53
+ # Windows
54
+ "The certificate's CN name does not match the passed value." ,
55
+ ],
56
+ )
42
57
failure_hosts_list = [
43
- FailureHost (
44
- host = "wrong.host.badssl.com" ,
45
- error_messages = [
46
- # OpenSSL
47
- "Hostname mismatch, certificate is not valid for 'wrong.host.badssl.com'" ,
48
- # macOS
49
- "certificate name does not match" ,
50
- # macOS with revocation checks
51
- "certificates do not meet pinning requirements" ,
52
- # macOS 10.13
53
- "Recoverable trust failure occurred" ,
54
- # Windows
55
- "The certificate's CN name does not match the passed value." ,
56
- ],
57
- ),
58
+ wrong_host_failure_host ,
58
59
FailureHost (
59
60
host = "expired.badssl.com" ,
60
61
error_messages = [
@@ -371,6 +372,21 @@ def test_requests_sslcontext_api_failures(failure):
371
372
assert "cert" in repr (e .value ).lower () and "verif" in repr (e .value ).lower ()
372
373
373
374
375
+ def test_wrong_host_succeeds_with_hostname_verification_disabled () -> None :
376
+ global wrong_host_failure_host
377
+
378
+ ctx = truststore .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
379
+ ctx .check_hostname = False
380
+ assert ctx .check_hostname is False
381
+
382
+ with urllib3 .PoolManager (ssl_context = ctx , retries = 5 , assert_hostname = False ) as http :
383
+ resp = http .request ("GET" , f"https://{ wrong_host_failure_host .host } " )
384
+
385
+ assert resp .status == 200
386
+ assert len (resp .data ) > 0
387
+ assert ctx .check_hostname is False
388
+
389
+
374
390
def test_trustme_cert (trustme_ca , httpserver ):
375
391
ctx = truststore .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
376
392
trustme_ca .configure_trust (ctx )
0 commit comments