Search code examples
flutterdartftp

Flutter FTPConnect HandshakeException error in connection with FTPS


I'm trying to make a FTPS connection in Flutter using the FTPConnect library, but it doesn't work.

My code:

FTPConnect ftpConnect = FTPConnect('devftp.made.net', user: 'user', pass: 'pass', showLog: kDebugMode, securityType: SecurityType.FTPS); 
await ftpConnect.connect();

Here is the log:

flutter: [2023-12-06 15:19:25.576751] Connecting... 

flutter: [2023-12-06 15:19:25.613803] Connection established, waiting for welcome message... 

flutter: [2023-12-06 15:19:25.918900] < FTPReply =  [code= 220, message= 220 Welcome on Made in App FTP server. Shaken, not stirred.] 

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: HandshakeException: Handshake error in client (OS Error:  
WRONG_VERSION_NUMBER(tls_record.cc:231)) #0      _SecureFilterImpl._handshake (dart:io-patch/secure_socket_patch.dart:99:46) #1      _SecureFilterImpl.handshake (dart:io-patch/secure_socket_patch.dart:143:25) #2      _RawSecureSocket._secureHandshake (dart:io/secure_socket.dart:920:54) #3      _RawSecureSocket._tryFilter (dart:io/secure_socket.dart:1049:19) <asynchronous suspension>

Of course, the provided credentials are not real.


Solution

  • SecurityType.FTPS is a non-standard FTP encryption mode.

    More common is the standard SecurityType.FTPES mode. I guess you should use that.