简体   繁体   English

如何在 Java 中通过 TLS/SSL (FTPS) 服务器连接到 FTP

[英]How to connect to FTP over TLS/SSL (FTPS) server in Java

I'm stuck in connecting to FTP over TLS/SSL (FTPS) server.我一直在通过 TLS/SSL (FTPS) 服务器连接到 FTP。 I am using SimpleFTP library through am able to connect FTP server without SSL but could not connect FTPS.我正在使用 SimpleFTP 库,因为我能够在没有 SSL 的情况下连接 FTP 服务器,但无法连接 FTPS。

It is giving me this error at line 2 (ftp.connect),它在第 2 行(ftp.connect)给了我这个错误,

SimpleFTP received an unknown response when connecting to the FTP server: SimpleFTP 连接到 FTP 服务器时收到未知响应:
220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220---------- 欢迎使用 Pure-FTPd [privsep] [TLS] ----------

and am using below code并且正在使用下面的代码

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();

The SimpleFTP class/library does not support TLS/SSL at all. SimpleFTP类/库根本不支持 TLS/SSL。


Use the FTPSClient class from the Apache Commons Net library instead.FTPSClient Apache Commons Net 库中FTPSClient

See the official example for the FTPClient class and just substitute the FTPClient with the FTPSClient .请参阅FTPClient官方示例,只需将FTPClient替换为FTPSClient

FTPSClient ftpClient = new FTPSClient();
ftpClient.connect(host);
ftpClient.login(user, password);

The FTPSClient class defaults to an explicit TLS/SSL (recommended). FTPSClient类默认为显式 TLS/SSL(推荐)。 In a rare case you need an implicit TLS/SSL, use new FTPSClient(true) .在极少数情况下,您需要隐式 TLS/SSL,请使用new FTPSClient(true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java中基于TLS / SSL(FTPS-隐式)服务器的Java FTP-若干错误 - Java FTP over TLS/SSL (FTPS- Implicit) Server in Java - Several Error "如何使用相同的 TLS 会话通过数据连接连接到 FTPS 服务器?" - How to connect to FTPS server with data connection using same TLS session? 使用SSL连接到FTP服务器的Java代码 - Java code to connect to FTP server using SSL 如何连接到一个停靠ssl / tls连接的docker守护进程 <HostVMIP> :2376使用Java? - How to connect to a docker daemon listening to ssl/tls connections over <HostVMIP>:2376 using Java? 我无法使用具有自定义SSLContext的Apache FTPSClient通过FTPS连接到FTP服务器-获取“无法识别的SSL消息,纯文本连接?” - I cannot connect to my FTP server by FTPS with Apache FTPSClient with custom SSLContext - getting “Unrecognized SSL message, plaintext connection?” 无法使用Java连接到FTPS(显式)服务器? - can not connect to FTPS (explicit) server with java? 用 Java 模拟 SFTP、FTP、FTPS、本地文件系统服务器 - Mocking SFTP, FTP, FTPS, Local File System Server in Java 通过TLS / SSL将RESTHeart连接到MongoDB - Connect RESTHeart to MongoDB over TLS/SSL 如何使用重用会话连接到 FTPS 服务器? - How to connect to FTPS server with reuse sessions? 连接到FTPS服务器 - Connect to FTPS server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM