无法用java连接到FTPS(显式)服务器?

时间:2014-09-17 11:29:36

标签: java ssl ftps apache-commons-net

我使用此代码连接到具有显式加密的ftps

String host = "10.21.13.66";
int port = 21;
String username = "user";
String password = "pass";
 try {
FTPSClient ftpClient = new FTPSClient("ssl",false);
ftpClient.addProtocolCommandListener(new PrintCommandListener(new  PrintWriter(System.out)));
ftpClient.connect(host, port);
int reply = ftpClient.getReplyCode();
if (FTPReply.isPositiveCompletion(reply)) {

// Login
(ftpClient.login(username, password)) 
}
} catch (IOException ioe) {
System.out.println("FTP client received network error");
}

当我尝试连接到我自己的ftps时,它返回此错误:431没有用于TLS / SSL加密的安全资源,可能没有选择的SSL证书

任何帮助将不胜感激;

1 个答案:

答案 0 :(得分:0)

尝试在构造对象后使用以下代码在ftps客户端上设置auth:

ftpClient.setAuthValue(" TLS&#34);