Skip to content

ext/openssl: Fix SNI certs not used on streams sharing a session SSL_CTX - #25398

Open
bukka wants to merge 1 commit into
php:PHP-8.6from
bukka:openssl_shared_ctx_sni
Open

bukka wants to merge 1 commit into
php:PHP-8.6from
bukka:openssl_shared_ctx_sni

Conversation

@bukka

@bukka bukka commented Nov 11, 2026

Copy link
Copy Markdown
Member

Since b1242c3 a server stream seeded from a session stream shares the parent's SSL_CTX and ignores its own context options. The SNI callback registered on that context looks up sni_certs of the stream doing the handshake, but the table stayed only on the parent, so the child always served the default certificate instead of the one matching the requested name.

This gives the child its own table that references the parent's per-name contexts (SSL_CTX_up_ref), so it also stays valid when the parent is closed first. It follows the same approach as the ALPN list copy in GH-25211.

Only 8.6 is affected. In 8.5 a server stream with a session stream still created its own context from its own options.

Since b1242c3 a server stream seeded from a session stream shares the
parent's SSL_CTX and ignores its own context options. The SNI callback
registered on that context looks up the certificate table of the stream
doing the handshake, but the table was left only on the parent, so the
child always served the default certificate. Give the child its own table
that references the parent's per-name contexts.
@bukka
bukka force-pushed the openssl_shared_ctx_sni branch from 412e114 to 91ad65f Compare November 11, 2026 18:00

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

lgtm

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.

2 participants