ftps传输encrypt data

来源:互联网 发布:知乎手机怎么回答 编辑:程序博客网 时间:2024/06/04 23:22

public static void main(String[] args) throws IOException, NoSuchAlgorithmException {
FTPSClient client = new FTPSClient();
client.connect("127.0.0.1");
client.execPROT("P"); // encrypt data channel
if (client.login("rory", "pass")) {
for (FTPFile file : client.listFiles()) { System.out.println(file.getName()); }
}
else { System.out.err(client.getReplyString()); }
}

Show
Rory Winston added a comment - 07/Feb/09 10:21 If the server is set to force data connections to be encrypted, then the client can issue a PROT command to encrypt data connections. See the example: public static void main(String[] args) throws IOException, NoSuchAlgorithmException { FTPSClient client = new FTPSClient(); client.connect("127.0.0.1"); client.execPROT("P"); // encrypt data channel if (client.login("rory", "pass")) { for (FTPFile file : client.listFiles()) { System.out.println(file.getName()); } } else { System.out.err(client.getReplyString()); } }
原创粉丝点击