I am trying to send a file to an FTPS server.
$conn_id = ftp_ssl_connect($ftp_server, $ftp_port);
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
ftp_set_option($conn_id, FTP_USEPASVADDRESS, false);
ftp_pasv($conn_id, true);
ftp_put($conn_id, $dest_file, $source_file, FTP_BINARY);
ftp_close($conn_id);
This gives me this error
Warning: ftp_put(): Data connection must use cached TLS session
or sometimes, when I change what file I am uploading, it gives me these errors:
Warning: ftp_put(): SSL write failed
Warning: ftp_put(): SSL_shutdown failed
Warning: ftp_put(): File status okay; about to open data connection.
I found a similar issue with fix for python FTPS with Python ftplib - Session reuse required
It appears that the server wants the data connections to use the same TLS session as the control connection. I don't have control over the server I am uploading to. I have tested the server with lftp and ensured that it works.
Is it possible to fix this with php's built in FTP library or should I find another FTP library (eg. cURL)?
As @sammitch mentioned in the comments this is a known bug until PHP version 8.2.14 and 8.3.1
As upgrading the PHP version we are using is a longer term task I opted to use PHP's builtin cURL bindings for now.