Skip to content

ext/openssl: Match IPv6 IPADDR SAN when connecting to bracketed URI#22038

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/openssl-ss007-ipv6-bracket-san
Open

ext/openssl: Match IPv6 IPADDR SAN when connecting to bracketed URI#22038
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/openssl-ss007-ipv6-bracket-san

Conversation

@iliaal
Copy link
Copy Markdown
Contributor

@iliaal iliaal commented May 13, 2026

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, so url_name ends up unset, the SAN matcher's inet_pton(AF_INET6, ...) call never happens, and verify_peer_name rejects every legitimate IPv6 target.

Handle the bare [host]:port shape 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 now sees ::1 and the 16-byte IPADDR SAN comparison body runs.

Covered by ext/openssl/tests/peer_verification_ipv6_san.phpt.

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.
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