“550 SSL/TLS required on the data channel” using Apache Commons FTPSClient

谁说我不能喝 提交于 2019-12-19 19:47:21

问题


I have a probleme reading data with FTPClient on a FTP-Server (ProFTPD 1.3.3a) that requires encryption on the data channel. Everything works fine without encryption on an other server.

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.

Any idea how to configure FTPSClient to use TLS/SSL on the data channel? Your help would be appreciated!


回答1:


You must enable data channel encryption before executing any commands that will transfer data over the data channel (such as LIST does).

Add this to your code after connecting to the server:

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

At least, this solved my problems (using proftpd).



来源:https://stackoverflow.com/questions/12492330/550-ssl-tls-required-on-the-data-channel-using-apache-commons-ftpsclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!