简体   繁体   中英

can not connect to FTPS (explicit) server with java?

I use this code to connect to ftps with explicit encryption

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");
}

when I try to connect to my own ftps it returns this error: 431 No security resource for TLS/SSL encryption, probably there is no selected SSL certificate

any help would be appreciated;

Try setting the auth on ftps client using below code after object is constructed:

ftpClient.setAuthValue("TLS");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM