gpt4 book ai didi

java - "550 SSL/TLS required on the data channel"使用 Apache Commons FTPSClient

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:51:10 26 4
gpt4 key购买 nike

我在需要加密数据通道的 FTP 服务器 (ProFTPD 1.3.3a) 上使用 FTPClient 读取数据时遇到问题。在其他服务器上没有加密的情况下一切正常。

我的代码是:

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();

我从输出中得到的是

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.

知道如何配置 FTPSClient 以在数据通道上使用 TLS/SSL 吗?非常感谢您的帮助!

最佳答案

在执行任何将通过数据通道传输数据的命令(例如 LIST 所做的)之前,您必须启用数据通道加密。

连接到服务器后将此添加到您的代码中:

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

至少,这解决了我的问题(使用 proftpd)。

关于java - "550 SSL/TLS required on the data channel"使用 Apache Commons FTPSClient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12492330/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com