FTPS:
一种多传输协议,相当于加密版的FTP。当你在FTP服务器上收发文件的时候,你面临两个风险。第一个风险是在上载文件的时候为文件加密。第二个风险是,这些文件在你等待接收方下载的时候将停留在FTP服务器上,这时你如何保证这些文件的安全。你的第二个选择(创建一个支持SSL的FTP服务器)能够让你的主机使用一个FTPS连接上载这些文件。这包括使用一个在FTP协议下面的SSL层加密控制和数据通道。一种替代FTPS的协议是安全文件传输协议(SFTP)。这个协议使用SSH文件传输协议加密从客户机到服务器的FTP连接。
FTPS是在安全套接层使用标准的FTP协议和指令的一种增强型FTP协议,为FTP协议和数据通道增加了SSL安全功能。FTPS也称作“FTP-SSL”和“FTP-over-SSL”。SSL是一个在客户机和具有SSL功能的服务器之间的安全连接中对数据进行加密和解密的协议。
当使用FTPS与服务器连接时,有两种方法:显式和隐式。
简单来说:
显示又叫FTPES, FTPS客户端跟FTPS服务器必须显式使用一种同样的加密方法。如果客户端不要求加密,服务器也允许非加密通讯。
隐式 就是客户端直接通过TSL/SSL加密与服务器联系,如果服务器无响应,则停止通讯。
FTP4J 支持 FTPS/FTPES secured connection,其中使用FTPES还是原来的21端口,使用FTPS使用的是990端口,使用SFTP的是22端口,以下说的不包含SFTP内容。
可以查看Serv-U域详细信息查看服务邦定的端口,默认情况下是以下内容:
如果我们使用flashfxp进行连接,则使用不同连接方式时要进行选择,普通FTP连接使用21端口,不用选择:
我们通过21端口进行显示FTPS连接:
package test; import it.sauronsoftware.ftp4j.FTPClient; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; /** * 通过21端口进行显示FTPS连接 * @说明 * @author cuisuqiang * @version 1.0 * @since */ public class Ftp4jTest { public static void main(String[] args) { try { TrustManager[] trustManager = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { } public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; SSLContext sslContext = null; sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, trustManager, new SecureRandom()); SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); FTPClient client = new FTPClient(); client.setSSLSocketFactory(sslSocketFactory); client.setSecurity(FTPClient.SECURITY_FTPES); client.connect("192.168.1.122", 21); client.login("123", "123123"); System.out.println(client.toString()); System.out.println(client.currentDirectory()); } catch (Exception e) { e.printStackTrace(); } } }
代码会打印连接信息和当前目录
使用990端口进行隐式FTPS连接:
package test; import it.sauronsoftware.ftp4j.FTPClient; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; /** * 进行隐式FTPS连接 * @说明 * @author cuisuqiang * @version 1.0 * @since */ public class Ftp4jTest { public static void main(String[] args) { try { TrustManager[] trustManager = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { } public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; SSLContext sslContext = null; sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, trustManager, new SecureRandom()); SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); FTPClient client = new FTPClient(); client.setSSLSocketFactory(sslSocketFactory); client.setSecurity(FTPClient.SECURITY_FTPS); client.connect("192.168.1.122", 990); client.login("123", "123123"); System.out.println(client.toString()); System.out.println(client.currentDirectory()); } catch (Exception e) { e.printStackTrace(); } } }
打印内容相同
进行显示还是隐式连接的最大不同是指定了连接方式:
这个情况官方也给出了详细的说明:
The ftp4j library supports both FTPS (FTP over implicit TLS/SSL) and FTPES (FTP over explicit TLS/SSL).
The setSecurity() method can be used to turn on the feature:
client.setSecurity(FTPClient.SECURITY_FTPS); // enables FTPS
client.setSecurity(FTPClient.SECURITY_FTPES); // enables FTPES
Both methods must be called before connecting the remote server.
If the security is set to SECURITY_FTPS, the default port used by the connect() method changes to 990
请您到ITEYE网站看原创,谢谢!
http://cuisuqiang.iteye.com/ !
自建博客地址:http://www.javacui.com/ ,内容与ITEYE同步!
相关推荐
NULL 博文链接:https://majg.iteye.com/blog/776224
java用ftp4j实现ftps加密上传 文档说的很详细,我也是找半天找弄出来的。 java用ftp4j实现ftps加密上传 文档说的很详细,我也是找半天找弄出来的。
支持FTP加密上传,1.4到1.7版本的包 Security Basic FTP authentication. FTPS (FTP over implicit TLS/SSL). FTPES (FTP over explicit TLS/SSL).
ftp4j ftp4j是ftp,ftps和ftpes协议的Java实现。 文物也通过github伪Maven存储库发布。 因此,如果要在您的maven项目中使用ftp4j作为依赖项,只需将以下存储库定义添加到pom.xml中<repositories> <repository> <id>...
(不过如果你需要FTPS及SFTP,那ftp4j不支持) jar包只有50多k,地址在这里:ftp4j 使用代理的代码: import java.util.ArrayList; import it.sauronsoftware.ftp4j.FTPClient; import it.sauronsoftware.ftp4j....
FTP,SFTP,FTPS总结
ftp&ftps使用问题总结.doc
使用FileZilla_Server搭建ftps和ftp服务器使用FileZilla_Server搭建ftps和ftp服务器使用FileZilla_Server搭建ftps和ftp服务器使用FileZilla_Server搭建ftps和ftp服务器
用Qt实现ftps服务器,实现数据的加密传送,保证了数据的可靠性和安全性。
ftp4j源码,可以参考这个做ftps的客户端。
JAVA遍历下载FTPS服务器上的文件,
ftps java实现
用于连接ftp服务器的工具,可以安装在pc电脑中,方便用于网络连接!
ftps和https双向认证 使用pfx和jks证书
本文通过libcurl实现ftp和ftps的文件上传
FileZilla服务器,FTP RFC959中文文档,Ftp传输协议,ftp连接指令,SSL安全协议(中文版),SSL协议的分析及实现
为Apache FtpServer 配置FTPS安全传输模式
用edtftpj.jar 实现的ftp client edtFTPj是一个非常强大的FTP组件,有Java版本、.NET版本、JavaScript版本。 Java版本的有收费的edtFTPj/PRO,还有免费开源的edtFTPj/Free。 这里使用edtFTPj/Free。 ...
FileZilla 客户端是一个快速可靠的、跨平台的FTP,FTPS和SFTP客户端。具有图形用户界面(GUI)和很多有用的特性。 相比较于其它FTP客户端,FileZilla 包含如下特性: 易于使用 支持FTP, FTP并支持SSL/TLS (FTPS)协议,...
版本是.net3.5加密FTP文件操作,利用FTPS实现文件上传,下载,删除操作。 string ftpIP = "";//FTP ip string ftpUSER = "";//FTP 用户名 string ftpPWD = "";//FTP 密码 --下载文件方法体 FTPSClient client = new...