File tree 1 file changed +3
-6
lines changed
1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -367,7 +367,9 @@ def _verify_peercerts_impl(
367
367
trust = None
368
368
cf_error = None
369
369
try :
370
- if server_hostname is not None :
370
+ # Only set a hostname on the policy if we're verifying the hostname
371
+ # on the leaf certificate.
372
+ if server_hostname is not None and ssl_context .check_hostname :
371
373
cf_str_hostname = None
372
374
try :
373
375
cf_str_hostname = _bytes_to_cf_string (server_hostname .encode ("ascii" ))
@@ -458,11 +460,6 @@ def _verify_peercerts_impl(
458
460
or cf_error_code == CFConst .errSecCertificateExpired
459
461
):
460
462
is_trusted = True
461
- elif (
462
- not ssl_context .check_hostname
463
- and cf_error_code == CFConst .errSecHostNameMismatch
464
- ):
465
- is_trusted = True
466
463
467
464
# If we're still not trusted then we start to
468
465
# construct and raise the SSLCertVerificationError.
You can’t perform that action at this time.
0 commit comments