Java – use Apache Commons ftpsclient to “require 550 SSL / TLS on data channel”

When I use ftpclient to read data on FTP server (proftpd 1.3.3a), I encounter a problem and need to encrypt the data channel Everything is normal and not encrypted on other servers

My code is:

FTPSClient ftpsClient = new FTPSClient("TLS",false);
log.debug("using TLS");
FTPClientConfig ftpClientConfig = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
ftpClientConfig.setServerLanguageCode("de");
ftpsClient.configure(ftpClientConfig);
ftpsClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); // outputs all conversation to the console
ftpsClient.connect(host,21);
ftpsClient.login(username,password);
ftpsClient.enterLocalPassiveMode();
ftpsClient.changeWorkingDirectory(pathname);
listNames = ftp.mlistDir();
ftpsClient.logout();

What I get from the output is

220 ProFTPD 1.3.3a Server (xxx) [xxx]
AUTH TLS
234 AUTH TLS successful
USER xxx
331 Password required for xxx
PASS xxx
230 User xxx logged in
CWD /www/catalog
250 CWD command successful
PASV
227 Entering Passive Mode (xxx).
MLSD
550 SSL/TLS required on the data channel
QUIT
221 Goodbye.

Do you know how to configure ftpsclient to use TLS / SSL on the data channel? Thank you very much for your help!

Solution

Data channel encryption must be enabled before executing any command that will transmit data over the data channel, such as list

After connecting to the server, add it to your code:

// Set protection buffer size
ftpClient.execPBSZ(0);
// Set data channel protection to private
ftpClient.execPROT("P");

At least, this solves my problem (using proftpd)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>