gpt4 book ai didi

java - 使用 commons-net 连接到 FTPS 服务器时为 "534 Policy requires SSL"

转载 作者:行者123 更新时间:2023-12-02 10:58:38 25 4
gpt4 key购买 nike

我正在尝试使用 commons-net 连接到 FTPS 服务器图书馆。我可以正确连接,但当我尝试列出文件时,收到错误“534 策略需要 SSL”。

import java.io.IOException;
import java.net.SocketException;

import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPSClient;
import org.apache.commons.net.util.TrustManagerUtils;

public class Test {

public static void main(String[] args) throws SocketException, IOException {
FTPSClient c = new FTPSClient("SSL", false);
c.setTrustManager(TrustManagerUtils.getValidateServerCertificateTrustManager());
c.connect("10.10.6.225", 21);
c.login("ftpuser", "Passw0rd");
c.changeToParentDirectory();
for (String s : c.getReplyStrings()) {
System.out.println(s);
}

c.listFiles();
for (String s : c.getReplyStrings()) {
System.out.println(s);
}
for (FTPFile f : c.listFiles("/TestFolder")) {
System.out.println("file");
System.out.println(f.getName());
}
c.disconnect();
}

}

最佳答案

登录后:

c.login("ftpuser", "Passw0rd");

尝试添加:

c.setFileType(FTP.BINARY_FILE_TYPE);
c.execPBSZ(0); // Set protection buffer size
c.execPROT("P"); // Set data channel protection to private
c.enterLocalPassiveMode();

关于java - 使用 commons-net 连接到 FTPS 服务器时为 "534 Policy requires SSL",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9416106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com