Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot make FTP with SSL work properly #1533

Closed
arxeiss opened this issue Aug 2, 2024 · 1 comment
Closed

Cannot make FTP with SSL work properly #1533

arxeiss opened this issue Aug 2, 2024 · 1 comment

Comments

@arxeiss
Copy link

arxeiss commented Aug 2, 2024

I'm trying to add FTP together with SSL myself as suggested by #1488 but it doesn't work for me properly, and after couple of days of debugging I'm lost.
I'm getting SSL_read on shutdown: error:0A000126:SSL routines::unexpected eof while reading in /ftp_test.php

Normally I'm using https://github.com/dg/ftp-deployment, but to mitigate risk that issue lives in that library, I prepared simple script and getting same result.

In the script below I'm getting that error on line with ftp_close($conn). If I delete that line, I get same error on line with unset($conn)

$url = parse_url("ftps://host.net/path/to/test/folder");

// Connect
$conn = ftp_ssl_connect($url["host"], 21) or die("Could not connect to");
ftp_login($conn, "username", "pass") or die("fail to login");
ftp_set_option($conn, FTP_USEPASVADDRESS, false) or die("fail to set option");
ftp_pasv($conn, true) or die("fail to set passive mode");
ftp_chdir($conn, $url['path']) or die("fail to change directory");

// Upload file
$path = "test-".date("Y-m-d_H-i-s").".txt";
file_put_contents($path, "test");
ftp_put($conn, $path, $path, FTP_BINARY) or die("fail to upload");

sleep(5);

ftp_close($conn) or die("fail to close");

unset($conn);

echo "done";

My Alpine Dockerfile is

FROM php:8.3-alpine

RUN apk update \
    && apk add --no-cache openssl-dev make git bash lftp coreutils

RUN docker-php-ext-configure ftp --with-openssl-dir=/usr \
    && docker-php-ext-install ftp

but I also tried non-alpine PHP image but with same result

FROM php:8.3

RUN apt-get update \
    && apt-get install -y libssl-dev make git bash lftp coreutils

RUN docker-php-ext-configure ftp --with-openssl-dir=/usr \
    && docker-php-ext-install ftp
@arxeiss
Copy link
Author

arxeiss commented Aug 2, 2024

So it actually works as expected (the Docker part). Because I'm getting same error even if I run that script locally on my machine with pure PHP installation.

I still struggle and I have no idea what is wrong. Especially because it happening on some FTP servers and not on others. But this is not Docker issue, so closing.

@arxeiss arxeiss closed this as completed Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant