我搜索了SO,谷歌搜索超过2天,没有找到任何帮助我的答案 .
我无法通过TLS / SSL(FTPS)服务器连接到FTP . 我正在使用SimpleFTP库,因为我可以连接没有SSL的FTP服务器,但无法连接FTPS .
它在第2行(ftp.connect)给我这个错误,
SimpleFTP在连接到FTP服务器时收到未知响应:220 ----------欢迎使用Pure-FTPd [privsep] [TLS] ----------
我正在使用下面的代码
SimpleFTP ftp = new SimpleFTP();
// Connect to an FTP server on port 21.
ftp.connect("xxx.xxx.xxx.xxx", 21, "username", "pwd");
//getting error at (ftp.connect) above line
// Set binary mode.
ftp.bin();
// Change to a new working directory on the FTP server.
ftp.cwd("web");
ftp.disconnect();
1 回答
SimpleFTP
类/库根本不支持TLS / SSL .请改用Apache Commons Net library中的FTPSClient class .
请参阅official example for the FTPClient class,然后将
FTPClient
替换为FTPSClient
.FTPSClient
类默认为显式TLS / SSL(推荐) . 在极少数情况下,您需要隐式TLS / SSL,请使用new FTPSClient(true)
.