[php-src] Issue #13022: Error occurred in ftp_get(session reuse required)
| From: | youichi0206 | Date: | Mon, 25 Dec 2023 11:09:03 +0000 |
| Subject: | [php-src] Issue #13022: Error occurred in ftp_get(session reuse required) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246124@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13022
Author: youichi0206
### Description
I want to download a file via ftp from a server with vftpd's require_ssl_reuse setting set to
YES, but an error occurs.
When using ftp get, "Warning: ftp_get(): SSL connection failed: session reuse required"
appears and file download fails.
When I connect to ftps using lftp, I can get ftp normally.
I would like to ask you to confirm.
OS:AlmaLinux 9.3
ftp server:vsftpd require_ssl_reuse=YES
require_ssl_reuse setting is YES
The following code:
```php
<?php
$ftpHost = 'xxx.jp';
$ftpUser = 'user';
$ftpPass = 'password';
$ftpServerDir = '/server/';
$FtpConnection = ftp_ssl_connect($ftpHost);
if ($FtpConnection == false) {
throw new \Exception('ftp connect failed');
}
$ftpReturn = ftp_login($FtpConnection, $ftpUser, $ftpPass);
if ($ftpReturn == false) {
throw new \Exception('ftp login failed');
}
$ftpReturn = ftp_pasv($FtpConnection, true);
if ($ftpReturn == false) {
throw new \Exception('ftp pasv failed');
}
$ftpReturn = ftp_chdir($FtpConnection, $ftpServerDir);
if ($ftpReturn == false) {
throw new \Exception('ftp ftp_chdir failed');
}
$remoteFileNames = ftp_nlist($FtpConnection, '.');
if ($remoteFileNames == false) {
throw new \Exception('ftp ftp_nlist failed');
}
$matchFileNames = (preg_grep('/ABC[0-9]{14}.csv/', $remoteFileNames));
foreach ($matchFileNames as $fileName) {
$remoteFileName = $fileName;
$localFileName = '/xxx/' . $fileName;
$ftpReturn = ftp_get($FtpConnection, $localFileName, $remoteFileName, FTP_BINARY); // Warning:
ftp_get(): SSL connection failed: session reuse required
if ($ftpReturn == false) {
throw new \Exception('ftp ftp_get failed');
}
$ftpReturn = ftp_delete($FtpConnection, $remoteFileName);
if ($ftpReturn == false) {
throw new \Exception('ftp ftp_delete failed');
}
}
$ftpReturn = ftp_close($FtpConnection);
if ($ftpReturn == false) {
throw new \Exception('ftp close failed');
}
```
Resulted in this output:
```
Warning: ftp_get(): SSL connection failed: session reuse required
```
### PHP Version
PHP 8.1.26
### Operating System
AlmaLinux 9.3