如何通过Java中的TLS / SSL(FTPS)服务器连接到FTP
发布时间:2020-12-15 00:02:40 所属栏目:Java 来源:网络整理
导读:我搜索了SO,谷歌搜索超过2天,没有找到任何帮助我的答案. 我无法通过TLS / SSL(FTPS)服务器连接到FTP.我正在使用SimpleFTP库,因为我可以连接没有SSL的FTP服务器,但无法连接FTPS. 它在第2行(ftp.connect)给我这个错误, SimpleFTP received an unknown response
我搜索了SO,谷歌搜索超过2天,没有找到任何帮助我的答案.
我无法通过TLS / SSL(FTPS)服务器连接到FTP.我正在使用SimpleFTP库,因为我可以连接没有SSL的FTP服务器,但无法连接FTPS. 它在第2行(ftp.connect)给我这个错误,
我正在使用下面的代码 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(); 解决方法
SimpleFTP类/库根本不支持TLS / SSL.
请使用Apache Commons Net library中的 请参阅official example for the FTPSClient ftpClient = new FTPSClient(); ftpClient.connect(host); ftpClient.login(user,password); FTPSClient类默认为显式TLS / SSL(推荐).在极少数情况下,您需要隐式TLS / SSL,请使用新的FTPSClient(true). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |