THRIFT-6201: Reduce IPv4-mapped addresses before matching a peer certificate - #3818
Conversation
|
@Jens-G, master has been red since d6782a87, and the cause is worth your attention beyond this PR. Run 34190474984 fails where the run before it passed. All 183 failures use the Your change replaced the Python 3.12 branch in the
So this PR alone does not turn CI green, and I did not want to decide the second point for you. The open question is whether Keeping the check means giving This comment was created with AI assistance. |
|
@slachiewicz — drop it as the default and keep it as an opt-in. Please go ahead with the follow-up. Why:
For the follow-up:
This comment was drafted with AI assistance. |
1dd4d9e to
f349d2a
Compare
…ificate Client: py A dual-stack listener reports an IPv4 peer as ::ffff:127.0.0.1 while the certificate carries the plain 127.0.0.1, and ipaddress compares the two as different addresses, so the peer was refused. Reduce both sides with ipv4_mapped before comparing. This alone does not make the SSL cross tests pass: test/keys/client.crt, which client.p12 wraps and the cross-test clients present, is signed without -extensions v3_req and so carries no subjectAltName for the matcher to read. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
f349d2a to
703622c
Compare
|
Rebased on master (703622c) to pick up the TNonblockingServerTest fix from THRIFT-6244 behind the AppVeyor failure. The diff is unchanged (same patch-id). |
JIRA: THRIFT-6201
Client: py
match_peer_ipaddresscompares the peer address to the certificate'ssubjectAltNameentries without reducing IPv4-mapped IPv6 addresses. A dual-stack listener reports an IPv4 peer as::ffff:127.0.0.1, a certificate normally carriesIP Address:127.0.0.1, andipaddresstreats those as different addresses, so the peer is refused:They are the same address, so both sides are reduced with
IPv6Address.ipv4_mappedbefore comparing.The test drives the matcher directly, in both directions and with two negatives (a different IPv4 address, and
::1against a certificate for127.0.0.1).Verified:
test_peer_address_matcher_unmaps_ipv4raises the message quoted above without the change and passes with it.Scope
The SSL cross tests pass on master without this change, because 715f46c moved the cross-test clients to
test/keys/client_v3.crt, which lists::ffff:127.0.0.1alongside127.0.0.1. A certificate issued outside this repository normally carries only the IPv4 form, and that is the case this fixes.Whether
TSSLServerSocketshould match a client certificate against the address the connection arrived from by default is THRIFT-6233, #3839. The matcher stays as the documented opt-in there, so a server that opts in sees both forms as the same address.The path only began running on Python 3.12 and later in 0.25.0; before that the shim on those versions was a function returning
True, so nothing reached the comparison.This change was created with AI assistance.