java – 使用Apache Commons FTPSClient在“数据通道上需要550 S
发布时间:2020-12-14 16:18:43 所属栏目:Java 来源:网络整理
导读:我在FTP服务器(ProFTPD 1.3.3a)上使用FTPClient读取数据时遇到问题,需要对数据通道进行加密.一切正常,没有加密在其他服务器上. 我的代码是: FTPSClient ftpsClient = new FTPSClient("TLS",false);log.debug("using TLS");FTPClientConfig ftpClientConfig
我在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). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |