【问题标题】:"534 Policy requires SSL" when connecting to an FTPS server with commons-net使用 commons-net 连接到 FTPS 服务器时出现“534 Policy requires SSL”
【发布时间】:2012-03-14 00:55:48
【问题描述】:

我正在尝试使用 commons-net 库连接到 FTPS 服务器。我可以正确连接,但是当我尝试列出文件时,我收到错误“534 Policy requires 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();
    }

}

【问题讨论】:

    标签: java ftps apache-commons-net


    【解决方案1】:

    登录后:

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

    【讨论】:

    • 谢谢 TC ,我的问题与此相同并已解决,但我的应用程序运行了 6 个月,但上周因“534 政策需要 SSL”而停止。在 storeFile 期间,为什么会这样?和网络配置有关吗?
    猜你喜欢
    • 1970-01-01
    • 2011-10-14
    • 2013-01-04
    • 2017-10-22
    • 2015-03-19
    • 1970-01-01
    • 2016-07-18
    • 2012-07-08
    • 1970-01-01
    相关资源
    最近更新 更多