Skip to content

FTP & SSL session reuse #9348

Closed
Closed

Description

@janpecha

Description

Hello,

FTP/SSL data connection fails after first data transfer, it results to error "425 Unable to build data connection: Operation not permitted".

The following code:

<?php

$f = ftp_ssl_connect('HOST');
ftp_login($f, 'USER', 'PASSWORD');
ftp_pasv($f, TRUE);
var_dump(ftp_nlist($f, '*'));
var_dump(ftp_nlist($f, '*'));

Resulted in this output:

array(2) {
  [0] =>
  string(4) "dirA"
  [1] =>
  string(9) "fileB.txt"
}
bool(false)

But I expected this output instead:

array(2) {
  [0] =>
  string(4) "dirA"
  [1] =>
  string(9) "fileB.txt"
}
array(2) {
  [0] =>
  string(4) "dirA"
  [1] =>
  string(9) "fileB.txt"
}

If I change code and try upload a file:

<?php
set_error_handler(function ($severity, $message) {
    echo $message;
});

$f = ftp_ssl_connect('HOST');
ftp_login($f, 'USER', 'PASSWORD');
ftp_pasv($f, TRUE);
ftp_fput($f, 'test-upload.txt', fopen(__DIR__ . '/my-file.txt', 'r'), FTP_BINARY);

It prints error 425 Unable to build data connection: Operation not permitted.

Links:

PHP Version

PHP 8.1.8 & all version from PHP 5.6

Operating System

Ubuntu 20.04

Activity

  1. simapple commented on Aug 17, 2022

    @simapple

    Could you list your ftp server's command logs ?

  2. janpecha commented on Aug 18, 2022

    @janpecha
    Author

    Sorry, I have no access to ftp server's logs.

  3. self-assigned this
    on Dec 1, 2023
  4. ndossche commented on Dec 1, 2023

    @ndossche
    Member

    I received a private reproducer from another person yesterday with the exact same issue.
    The issue is related to our session resumption code, I have a local patch that fixes is but I have to double check the correctness.

  5. added a commit that references this issue on Dec 2, 2023
    1018e47
  6. linked a pull request that will close this issueFix GH-9348: FTP & SSL session reuse #12851on Dec 2, 2023
  7. added 2 commits that reference this issue on Dec 2, 2023
    addb6e4
    f601963
  8. added a commit that references this issue on Jan 25, 2024
    ac8a58f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions