sKunKbad Posted June 4, 2012 Share Posted June 4, 2012 I've been trying to connect to a CentOS server with ftp_ssl_connect, and I just get errors, even though I can successfully connect with FileZilla using FTPeS. These are the errors: Warning: ftp_login() [function.ftp-login]: SSL/TLS handshake failed in C:\xampp\htdocs\script-library\connectivity\connectivity.php on line 72 Warning: ftp_login() [function.ftp-login]: Proceed with negotiation. in C:\xampp\htdocs\script-library\connectivity\connectivity.php on line 72 The server has vsftpd for ftp. It is configured for SSL, and again it works with FileZilla FTP client, so I don't know why it doesn't work with my PHP. Other than the above error messages, I don't really know how to debug or get more info. $ftp_server = '123.123.123.123'; $ftp_user_name = 'username'; $ftp_user_pass = 'xxxxxxxxx'; $file = 'test.txt'; $remote_file = 'test.txt'; $remote_directory = '/home/username'; $ftp_output = ''; // Test if connection is HTTP or HTTPS if ( isset( $_POST['do_ftp'] ) && $_POST['do_ftp'] == '1' ) { if( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' && function_exists('ftp_ssl_connect') ) { // Set up secure ftp connection $conn_id = @ftp_ssl_connect( $ftp_server ); } else { // Set up standard ftp connection $conn_id = @ftp_connect( $ftp_server ); } } // Check if connection was made if( is_resource( $conn_id ) ) { $ftp_output .= '<span class="good">FTP CONNECTION SUCCESSFUL</span><br />'; // Login with username and password if( $login_result = ftp_login( $conn_id, $ftp_user_name, $ftp_user_pass ) ) { $ftp_output .= '<span class="good">FTP LOGIN SUCCESSFUL</span><br />'; // Turn passive mode on ftp_pasv( $conn_id, TRUE ); // CD to the appropriate directory ftp_chdir( $conn_id, $remote_directory ); // Upload a file if ( ftp_put( $conn_id, $remote_file, $file, FTP_ASCII ) ) { $ftp_output .= '<span class="good">FTP UPLOAD OF ' . $file . ' SUCCESSFUL</span><br />'; } else { $ftp_output .= '<span class="bad">FTP UPLOAD OF ' . $file . ' FAILED</span><br />'; } } else { $ftp_output .= '<span class="bad">FTP LOGIN FAILED</span><br />'; } // Close the FTP connection ftp_close( $conn_id ); } else if( isset( $conn_id ) ) { $ftp_output .= '<span class="bad">FTP CONNECTION FAILED</span><br />'; } Output from FTP: FTP CONNECTION SUCCESSFUL FTP LOGIN FAILED Link to comment https://forums.phpfreaks.com/topic/263647-need-help-with-ftp_ssl_connect/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.