Como se ligar ao FTP através do servidor TLS / SSL (FTPS) em Java
Procurei assim, pesquisei mais de 2 dias no Google e não encontrei nenhuma resposta que me ajudasse.
Estou preso na ligação ao FTP sobre o servidor TLS / SSL (FTPS). Eu estou usando a Biblioteca SimpleFTP através de AM capaz de conectar o servidor FTP sem SSL, mas não poderia conectar FTPS.
está a dar-me este erro na linha 2 (ftp.connect),
a SimpleFTP recebeu uma resposta desconhecida ao ligar-se ao servidor FTP:
220---------- Bem-vindo ao Pure-FTPd [privsep] [TLS] ----------
e am usando o código abaixo
SimpleFTP ftp = new SimpleFTP();
// Connect to an FTP server on port 21.
ftp.connect("xxx.xxx.xxx.xxx", 21, "username", "pwd");
//getting error at (ftp.connect) above line
// Set binary mode.
ftp.bin();
// Change to a new working directory on the FTP server.
ftp.cwd("web");
ftp.disconnect();
6
Author: Martin Prikryl, 2016-03-30
1 answers
A SimpleFTP
classe / biblioteca não suporta de todo o TLS/SSL.
FTPSClient
class from theApache Commons Net library instead.
Veja o exemplo oficial da classe FTPClient
e substitua oFTPClient
pelo FTPSClient
.
FTPSClient ftpClient = new FTPSClient();
ftpClient.connect(host);
ftpClient.login(user, password);
A classe FTPSClient
corresponde por omissão a um TLS/SSL explícito (recomendado). Num caso raro, necessita de um TLS/SSL implícito, use new FTPSClient(true)
.
12
Author: Martin Prikryl, 2017-02-11 10:40:04