Skip to content

Commit fdcb7aa

Browse files
committed
Only provide a hostname to SecCreatePolicySSL when verifying
1 parent 2a9bf4f commit fdcb7aa

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/truststore/_macos.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ def _verify_peercerts_impl(
386386
policies = None
387387
trust = None
388388
try:
389-
if server_hostname is not None:
389+
# Only set a hostname on the policy if we're verifying the hostname
390+
# on the leaf certificate.
391+
if server_hostname is not None and ssl_context.check_hostname:
390392
cf_str_hostname = None
391393
try:
392394
cf_str_hostname = _bytes_to_cf_string(server_hostname.encode("ascii"))
@@ -539,11 +541,6 @@ def _verify_peercerts_impl_macos_10_14(
539541
or cf_error_code == CFConst.errSecCertificateExpired
540542
):
541543
is_trusted = True
542-
elif (
543-
not ssl_context.check_hostname
544-
and cf_error_code == CFConst.errSecHostNameMismatch
545-
):
546-
is_trusted = True
547544

548545
# If we're still not trusted then we start to
549546
# construct and raise the SSLCertVerificationError.

0 commit comments

Comments
 (0)