java - FTPS协议版本
问题描述
我正在尝试连接到 ftps 服务器,但我一直都有 SSL 异常“收到致命警报:protocol_version”。我修改了我的代码 1000 次以寻找正确的实现,但每次都出现相同的错误(我的 jar 在 java7 中运行)
我尝试了什么:
- Java8
- 更改 Java 面板控件以接受不同的 TLS 版本
- 以显式模式连接并设置端口 21。
我的代码:
public FTPConnection(String host, String username, String password, boolean passive) throws IOException {
this.host = host;
System.setProperty("jdk.tls.useExtendedMasterSecret", "false");
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
this.clientFtps = new FTPSClient("TLS", false);
try{
this.clientFtps.connect(host, 21);
}catch (SSLException e){
log.debug(" port : " + this.clientFtps.getDefaultPort() + " Reply : " + this.clientFtps.getReplyString());
log.debug("catched exception : " + e);
}
if (username != null)
try{
if (pasv) {
this.clientFtps.enterLocalPassiveMode();
} else {
this.clientFtps.enterLocalActiveMode();
}
this.clientFtps.login(username, password);
log.debug(this.clientFtps.getReplyString());
}
catch (IOException ex){
ex.printStackTrace();
}
this.clientFtps.setFileType(FTP.BINARY_FILE_TYPE);
this.clientFtps.setFileTransferMode(FTP.BINARY_FILE_TYPE);
log.debug("the type of ftp file is : " + FTP.BINARY_FILE_TYPE);
}
我的错误:
捕获的异常:javax.net.ssl.SSLException:收到致命警报:protocol_version
服务器返回什么:
https.protocols : TLSv1,TLSv1.1,TLSv1.2 端口: 21 回复: 234 AUTH TLS 成功
解决方案
推荐阅读
- sql-server - Lucee 5.3.3.62 - 错误 - 无法打开登录请求的数据库“半影”。登录失败。客户端连接 ID
- laravel - Laravel 检查是否正在运行触发 SSE 的 artisan 命令
- python - 为什么python读取文件中的信息而不是它的内容?
- talend - 如何从 Talend 中的单个 tDBinput 获取多个结果集?
- java - 如何从类中的 strings.xml 获取字符串?
- asp.net-core - NuGet 包将不会安装
- python - 为什么 np.add.at() 对大型数组返回错误的答案?
- javascript - API 在 HTML 中显示 undefined 而不是值
- c# - 如何从 C# 控制台应用程序自动启动 Zoom 会议
- javascript - 如何删除除 1 条具有消息 ID 的特定消息之外的所有消息?