Skip to content

ext/openssl: Fix GH-25088: SNI server contexts do not inherit the base policy - #25113

Open
Roman3349 wants to merge 2 commits into
php:PHP-8.4from
Roman3349:fix/gh-25088-sni-ctx-inherit-policy
Open

Roman3349 wants to merge 2 commits into
php:PHP-8.4from
Roman3349:fix/gh-25088-sni-ctx-inherit-policy

Conversation

@Roman3349

Copy link
Copy Markdown
Contributor

The SNI callback switches the handshake to the per-host SSL_CTX, from which OpenSSL takes the cipher list, ALPN callback, DH params and security level. Apply the ciphers, alpn_protocols, dh_param and security_level options to the per-host contexts too.

Fixes GH-25088

@Roman3349
Roman3349 requested a review from bukka as a code owner October 31, 2026 20:36
@Roman3349 Roman3349 changed the title Fixed GH-25088: SNI server contexts do not inherit the base policy ext/openssl: Fixed GH-25088: SNI server contexts do not inherit the base policy Oct 31, 2026
@Roman3349
Roman3349 changed the base branch from master to PHP-8.4 October 31, 2026 20:37
@Roman3349 Roman3349 changed the title ext/openssl: Fixed GH-25088: SNI server contexts do not inherit the base policy ext/openssl: Fix GH-25088: SNI server contexts do not inherit the base policy Oct 31, 2026
@Roman3349
Roman3349 force-pushed the fix/gh-25088-sni-ctx-inherit-policy branch from 20525c5 to ddd1f9e Compare October 31, 2026 21:08

@bukka bukka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense. It could break potentially someone but I think everyone would expect to have those option inherited so it seems more like a bug fix to me.

I got just NIT's

Comment thread ext/openssl/tests/gh25088.phpt Outdated
--SKIPIF--
<?php
if (!function_exists("proc_open")) die("skip no proc_open");
if (!defined("OPENSSL_VERSION_NUMBER") || OPENSSL_VERSION_NUMBER < 0x10101000) die("skip OpenSSL 1.1.1+ required");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.1.1 is minimum so no need to check this.

Comment thread ext/openssl/xp_ssl.c Outdated
Comment on lines +1460 to +1463
/* SSL_set_SSL_CTX() in the SNI callback switches the handshake to the per-host
* context, so the cipher list, ALPN selection callback, DH parameters and
* security level are taken from that context instead of the base one. Apply
* the base context policy to the per-host context. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use that long comment - reduce to one line or so.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well I prefer to usually reduce them but they sometime slip in - in this case it's too much explaining though.

Comment thread ext/openssl/xp_ssl.c Outdated

return SUCCESS;
}
/* }}} */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The {{{ and }}} are not used for new functions so please remove it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in other new functions as well.

The SNI callback switches the handshake to the per-host SSL_CTX, from which
OpenSSL takes the cipher list, ALPN callback, DH params and security level.
Apply the ciphers, alpn_protocols, dh_param and security_level options to
the per-host contexts too.

Fixes phpGH-25088

Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
@Roman3349
Roman3349 force-pushed the fix/gh-25088-sni-ctx-inherit-policy branch from ddd1f9e to e7c84f8 Compare November 11, 2026 19:19
@Roman3349
Roman3349 requested a review from bukka November 11, 2026 19:21
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.

[ext/openssl] SNI server contexts do not inherit ciphers or ALPN policy

2 participants