[php-src] PR #12851: Fix GH-9348: FTP & SSL session reuse

From: Date: Sat, 02 Dec 2023 15:39:59 +0000
Subject: [php-src] PR #12851: Fix GH-9348: FTP & SSL session reuse
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-24397@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/12851 Author: nielsdos The issue referenced here doesn't contain a reproducer, but I recently received an email of a user with the exact same problem. I was able to recreate the scenario locally using vsftpd and setting require_ssl_reuse=YES in the vsftpd configuration. It turns out that our session resumption code is broken. It only works a single time: the first time a data connection opens. Subsequent data connections fail to reuse the session. This is because on every data connection a new session is negotiated, but the current code always tries to reuse the (stale) session of the control connection. To fix this, we use SSL_CTX_sess_set_new_cb() to setup a callback that gets called every time a new session is negotiated. We take a strong reference using SSL_get1_session() and store it in the ftpbuf_t struct. Every time we open a data connection we'll take that session. This works because every control connection has at most a single associated data connection. Also disable internal session caching storage to not fill the cache up with useless sessions. There is no phpt for this because PHP does not support enforcing SSL session reuse. It is however testable manually by setting up vsftpd and setting the require_ssl_reuse=YES function from before.

« previous php.git-pulls (#24397) next »