[php-src] master: Merge branch 'PHP-8.6'

From: Date: Thu, 05 Nov 2026 13:52:13 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143352@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2026-11-05T13:51:47Z Commit: https://github.com/php/php-src/commit/49d3049dd9d26b5c2bf0690f1140529cc81c0144 Raw diff: https://github.com/php/php-src/commit/49d3049dd9d26b5c2bf0690f1140529cc81c0144.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix GH-25172: ext/openssl: session reuse sharing callbacks with persistent stream Changed paths: A ext/openssl/tests/gh25172.phpt M ext/openssl/xp_ssl.c Diff: diff --git a/ext/openssl/tests/gh25172.phpt b/ext/openssl/tests/gh25172.phpt new file mode 100644 index 000000000000..8cd231e1b988 --- /dev/null +++ b/ext/openssl/tests/gh25172.phpt @@ -0,0 +1,49 @@ +--TEST-- +GH-25172: TLS session reuse must not share callbacks with a persistent stream +--EXTENSIONS-- +openssl +--CREDITS-- +cxxz16 +--FILE-- +<?php +function reuse_on_persistent(array $options, int $method): void { + $server = stream_socket_server('tcp://127.0.0.1:0'); + $addr = stream_socket_get_name($server, false); + [$host, $port] = explode(':', $addr); + + $ctx = stream_context_create(['ssl' => $options]); + $parent = stream_socket_client("tcp://$addr", $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $ctx); + stream_set_blocking($parent, false); + var_dump(stream_socket_enable_crypto($parent, true, $method)); + + $child = pfsockopen($host, (int) $port); + stream_set_blocking($child, false); + var_dump(stream_socket_enable_crypto($child, true, $method, $parent)); +} + +reuse_on_persistent( + ['psk_client_cb' => fn() => new Openssl\Psk(str_repeat('k', 32), 'id')], + STREAM_CRYPTO_METHOD_TLS_CLIENT, +); +reuse_on_persistent( + ['session_new_cb' => function () {}], + STREAM_CRYPTO_METHOD_TLS_CLIENT, +); +reuse_on_persistent( + ['early_data_cb' => function () {}], + STREAM_CRYPTO_METHOD_TLS_SERVER, +); +?> +--EXPECTF-- +int(0) + +Warning: stream_socket_enable_crypto(): Supplied SSL session stream with callbacks is not supported for persistent streams in %s on line %d +int(0) +int(0) + +Warning: stream_socket_enable_crypto(): Supplied SSL session stream with callbacks is not supported for persistent streams in %s on line %d +int(0) +int(0) + +Warning: stream_socket_enable_crypto(): Supplied SSL session stream with callbacks is not supported for persistent streams in %s on line %d +int(0) diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 35cbb84d30d8..65d88b5504ec 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -2789,6 +2789,14 @@ static zend_result php_openssl_setup_crypto(php_stream *stream, php_stream_warn(stream, SslNotSupported, "Supplied SSL session stream is not set up"); } else if (sslsock->is_client && parent_sslsock->ssl_handle == NULL) { php_stream_warn(stream, SslNotSupported, "Supplied SSL session stream is not initialized"); + } else if (php_stream_is_persistent(stream) && + (parent_sslsock->session_callbacks + || parent_sslsock->psk_callbacks +#if defined(HAVE_TLS13) + || parent_sslsock->early_data_callbacks +#endif + )) { + php_stream_warn(stream, PersistentNotSupported, "Supplied SSL session stream with callbacks is not supported for persistent streams"); } else { SSL_CTX_up_ref(parent_sslsock->ctx); sslsock->ctx = parent_sslsock->ctx;

« previous php.cvs (#143352) next »