java使用FTPS TLS连接到FTP
尝试使用FTP连接到FTP服务器(“TLS”,隐式)时出错
FTPSClient ftps = new FTPSClient("TLS");
ftps.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
int reply;
try {
ftps.connect("server");
} catch (IOException ex) {
Logger.getLogger(Ftpimport.class.getName()).log(Level.SEVERE, null, ex);
}
reply = ftps.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
try {
ftps.disconnect();
} catch (IOException ex) {
Logger.getLogger(Ftpimport.class.getName()).log(Level.SEVERE, null, ex);
}
throw new Exception("Exception in connecting to FTPs Server");
}
ftps.execPBSZ(0);
ftps.execPROT("P");
ftps.login("user", "pass");
ftps.setFileType(FTP.BINARY_FILE_TYPE);
ftps.enterLocalPassiveMode();
它在“234 AUTH命令正常。期待TLS协商”中出现使用SSLContext和TrustManager进行了尝试,但都是一样的
共 (0) 个答案