Use sslcompat hostname matcher in TSSLSocket#3413
Merged
Jens-G merged 1 commit intoapache:masterfrom Apr 22, 2026
Merged
Conversation
Client: py The module-level _match_hostname was defined inline as a no-op lambda, shadowing the more complete implementation already exported by sslcompat. Use the sslcompat version directly, removing the duplicate definition. Python 3.12+ removed ssl.match_hostname entirely; the sslcompat fallback is a no-op on that version by design. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mhlakhani
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TSSLSocket.pydefined_match_hostnameas a module-level no-op lambda, shadowing the more complete implementation already exported by the companionsslcompatmodule. Thesslcompatmodule exists specifically to abstract over Python version differences inssl.match_hostname: it provides the real implementation on Python < 3.12 and a no-op on Python 3.12+ (wheressl.match_hostnamewas removed and hostname verification is handled entirely by OpenSSL viacheck_hostname=True).This change:
lib/py/src/transport/TSSLSocket.py: imports_match_hostnamefromsslcompatalongside the existing_match_has_ipaddressimport; removes the inline no-op lambda definition.Tests added in
lib/py/test/test_sslsocket.py(TestMatchHostnameclass):test_match_hostname_is_from_sslcompat: assertsTSSLSocket._match_hostname is sslcompat._match_hostname.test_match_hostname_rejects_mismatch: on Python < 3.12, verifies a hostname mismatch raises an exception (skipped on 3.12+ wheressl.match_hostnameno longer exists).Test plan
python3 lib/py/test/test_sslsocket.py -v— two new matcher tests pass🤖 Generated with Claude Code