ext/openssl: Match IPv6 IPADDR SAN when connecting to bracketed URI#22038
Open
iliaal wants to merge 1 commit into
Open
ext/openssl: Match IPv6 IPADDR SAN when connecting to bracketed URI#22038iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
php_openssl_get_url_name() returns NULL for resourcenames of the form "[::1]:port" because php_url_parse_ex() cannot extract a host from a bracketed hostport when no scheme is present. With url_name unset, the SAN matcher falls back to peer_name which is also unset under default client config, so verify_peer_name silently rejects every IPv6 literal target even when the cert carries the matching IPADDR SAN entry. Handle the bare "[host]:port" form before php_url_parse_ex() and strip surrounding brackets on the parse path for callers that pass a full "ssl://[::1]:port" URL. The SAN matcher's inet_pton(AF_INET6, ...) call now sees "::1" instead of "[::1]" and the 16-byte IPADDR SAN comparison body runs.
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.
Default-config TLS client cannot match an IPADDR SAN entry covering an IPv6 literal because
php_openssl_get_url_name()returns NULL for resourcenames of the form[::1]:port.php_url_parse_ex()cannot extract a host from a bracketed hostport when no scheme is present, sourl_nameends up unset, the SAN matcher'sinet_pton(AF_INET6, ...)call never happens, andverify_peer_namerejects every legitimate IPv6 target.Handle the bare
[host]:portshape beforephp_url_parse_ex()and strip surrounding brackets on the parse path for callers that pass a fullssl://[::1]:portURL. The SAN matcher now sees::1and the 16-byte IPADDR SAN comparison body runs.Covered by
ext/openssl/tests/peer_verification_ipv6_san.phpt.