简体   繁体   English

使用SSL连接Apache FtpServer时出错

[英]Error when using SSL to connect to Apache FtpServer

I'm trying to set up a simple test FTP server using Apache FtpServer, and I'm having trouble configuring to use SSL.我正在尝试使用 Apache FtpServer 设置一个简单的测试 FTP 服务器,但在配置使用 SSL 时遇到问题。

Following the Apache FtpServer documentation , here is what my code looks like so far:遵循Apache FtpServer 文档,这是我的代码到目前为止的样子:

        FtpServerFactory ftpServerFactory = new FtpServerFactory();
        ListenerFactory listenerFactory = new ListenerFactory();
        listenerFactory.setPort(990);
        listenerFactory.setServerAddress("example.com");

        SslConfigurationFactory sslConfigurationFactory = new SslConfigurationFactory();
        sslConfigurationFactory.setKeystoreFile(JKS);
        sslConfigurationFactory.setKeystorePassword(JKS_PASS);
        listenerFactory.setSslConfiguration(sslConfigurationFactory.createSslConfiguration());
        listenerFactory.setImplicitSsl(true);

        ftpServerFactory.addListener("default", listenerFactory.createListener());

        PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
        userManagerFactory.setFile(USERS_PATH.toFile());

        BaseUser test = new BaseUser();
        sample1.setName("test");
        sample1.setPassword("test");
        sample1.setHomeDirectory(HOME.getAbsolutePath().toString());
        test.setAuthorities(List.of(new WritePermission());

        UserManager userManager = userManagerFactory.createUserManager();
        try {
            userManager.save(test);
        }
        catch (FtpException e) {
            e.printStackTrace();
        }

        ftpServerFactory.setUserManager(userManager);

        FtpServer server = ftpServerFactory.createServer();
        try {
            server.start();
        }
        catch (FtpException e) {
            e.printStackTrace();
        }

When I try to connect to the FTPS server, I get this error from the server:当我尝试连接到 FTPS 服务器时,我从服务器收到此错误:

[main] INFO org.apache.ftpserver.impl.DefaultFtpServer - FTP server started
[NioProcessor-1] WARN org.apache.mina.util.DefaultExceptionMonitor - Unexpected exception.
org.apache.mina.core.filterchain.IoFilterLifeCycleException: onPreAdd(): sslFilter:SslFilter in (0x00000002: nio socket, server, /2.51.214.102:50475 => /142.93.208.41:990)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.register(DefaultIoFilterChain.java:465)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.addLast(DefaultIoFilterChain.java:234)
    at org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder.buildFilterChain(DefaultIoFilterChainBuilder.java:553)
    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.addNow(AbstractPollingIoProcessor.java:832)
    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.handleNewSessions(AbstractPollingIoProcessor.java:752)
    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:652)
    at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: Unsupported protocolTLS
    at java.base/sun.security.ssl.ProtocolVersion.namesOf(ProtocolVersion.java:292)
    at java.base/sun.security.ssl.SSLEngineImpl.setEnabledProtocols(SSLEngineImpl.java:798)
    at org.apache.mina.filter.ssl.SslHandler.init(SslHandler.java:184)
    at org.apache.mina.filter.ssl.SslFilter.onPreAdd(SslFilter.java:458)
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.register(DefaultIoFilterChain.java:463)
    ... 9 more

From my client (FileZilla), I get this error:从我的客户(FileZilla),我得到这个错误:

Status:         Resolving address of itgsiatest.duss.app
Status:         Connecting to 142.93.208.41:990...
Status:         Connection established, initializing TLS...
Status:         Connection attempt failed with "ECONNRESET - Connection reset by peer".
Error:          Could not connect to server

Is there anything I missed?有什么我错过的吗?

You are going into not documented waters.您将进入未记录的水域。

  1. I assume you have managed to setup the FTP server without encryption standalone .我假设您已经成功设置了 FTP 服务器,无需单独加密
  2. I assume you have managed to set the FTP server with encryption standalone .我假设您已经设法将 FTP 服务器设置为独立加密
  3. I assume you have managed to setup the FTP server without encryption embedded .我假设您已经设法设置了 FTP 服务器,没有嵌入加密
  4. Now you are trying to combine encryption and embedding .现在您正在尝试将加密和嵌入结合起来。 It means you need to apply all the configuration changes differing between steps 1 and 2 via code added to step 3.这意味着您需要通过添加到第 3 步的代码应用第 1 步和第 2 步之间不同的所有配置更改。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM