Skip to content

THRIFT-6233: Make the peer-address check on TSSLServerSocket opt-in - #3839

Draft
slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:THRIFT-6233
Draft

THRIFT-6233: Make the peer-address check on TSSLServerSocket opt-in#3839
slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:THRIFT-6233

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Sep 11, 2026

Copy link
Copy Markdown
Member

Follow-up agreed on #3818: TSSLServerSocket no longer matches a client certificate against the address the connection arrived from unless the caller asks for it. validate_callback now defaults to None; OpenSSL still verifies the certificate against ca_certs when cert_reqs asks for one, and validate_callback=thrift.transport.sslcompat.match_peer_ipaddress brings the address check back. TSSLSocket and sslcompat._match_hostname are unchanged. The _match_has_ipaddress guard in TSSLServerSocket.__init__ goes with the default. Both readmes carry the note for servers on Python 3.11 or earlier that relied on the check.

Two choices worth a look:

  • test/py/TestServer.py opts in with validate_callback=match_peer_ipaddress, so the cross-test keeps exercising the address path, including the IPv4-mapped form THRIFT-6201: Reduce IPv4-mapped addresses before matching a peer certificate #3818 fixes. Dropping it would leave that path with unit coverage only.
  • The new tests name ssl_version=ssl.PROTOCOL_TLS_SERVER, as TestServer.py already does. A TSSLServerSocket built without ssl_version gets the class default PROTOCOL_TLS_CLIENT, whose context requires a server_hostname, and accept() fails with ValueError: check_hostname requires server_hostname. That is unchanged by this PR. The default dates from 7ec4177 (October 2024, first released in 0.22.0); TSSLSocketTest was already skipped in April 2023, so the two are unrelated. It needs a ticket of its own, which I can file.

Verified: python test/test_sslsocket.py → 20 tests, 3 new, OK with the 12 skips as before; with the library change stashed, test_client_cert_without_address_accepted_by_default fails.

This change was created with AI assistance.

Client: py

The default validate_callback matched a client certificate against the
address the connection arrived from, which no other binding does and
which a client certificate often cannot satisfy behind NAT or a proxy.
The default is now None; pass validate_callback=match_peer_ipaddress
to keep the check.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@slachiewicz

Copy link
Copy Markdown
Member Author

Rebased on master (42d6fb0) to pick up the TNonblockingServerTest fix from THRIFT-6244 behind the AppVeyor failure. The diff is unchanged (same patch-id).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant