Hi guys,

Im trying to use the fsockopen for TLS FTP login.

The PHP manual says :

As of PHP 4.3.0, if you have compiled in OpenSSL support, you may prefix the hostname with either 'ssl://' or 'tls://' to use an SSL or TLS client connection over TCP/IP to connect to the remote host

Okie dokie arthieshokie lets try it out:

<?

$server="tls://ftp-ip.com";
$port = 123;
sock = fsockopen($server, $port, $errno, $errstr, $timeout);

Returns:

Trying to "tls://ftp-ip.com" ...

Warning: fsockopen() [function.fsockopen]: php_stream_sock_ssl_activate_with_method: SSL handshake/connection failed in /glftpdclass.php on line 204

Warning: fsockopen() [function.fsockopen]: failed to activate SSL mode 1 in glftpdclass.php on line 204
-2.0-OpenSSH_3.4p1
500 '€Z': Command not understood.

I realy expected it would be similare to ftp_ssl_connect(), what is working really fine in that case. But it doesnt return a filepointer like fsockopen to use fgets, fputs etc. So i can use that function.

Maybe its a bug 😕

Looks like, cause fsockopen cant handle the handshake when login to a security FTP by using TLS.

Or do i have to send the handshake tru fputs $sock("AUTH TLS") + cert from openssl handy ???

But why does fsockopen support tls then ?
Why doesnt do it a handshake ??
Why fsockopen(tls or ssl then) ?

Maybe i can get any help here, what im doing wrong ?

I realy stick on it and help or any codesnippet "how to login FTP using TLS/SSL+fsockopen" is welcome.

Maybe....

Thank you for help !

    Write a Reply...