【问题标题】:How to create DefaultFtpsSessionFactory instance with the help of certificate如何借助证书创建 DefaultFtpsSessionFactory 实例
【发布时间】:2018-08-07 20:13:31
【问题描述】:

我正在尝试将org.springframework.integration.ftp.session.DefaultFtpsSessionFactory 用于我的 FTPS 客户端,但我没有用户 ID 或密码。我有 *.cer 文件。如何使用证书创建会话工厂实例。到目前为止,我已经看过了

https://docs.spring.io/spring-integration/reference/html/ftp.html

http://tutorials.jenkov.com/java-cryptography/certificatefactory.html

How do I configure client authentication with generated certificate in apache-commons net

https://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClient.html

我只是找不到在创建 ftpsclient 时使用证书的任何直接用法。

【问题讨论】:

    标签: java spring-integration


    【解决方案1】:

    我还没有这样做,但我认为您必须创建DefaultFtpsSessionFactory 的子类,覆盖createClientInstance() 以使用采用SSLContextFTPSClient 构造函数之一。

    您必须使用已从包含证书的密钥库初始化的 KeyManager 初始化 SSL 上下文。

    spring-integration-ip 拥有some code that does this for TCP connections

    【讨论】:

    • 看来他对username也有顾虑,反正AbstractFtpSessionFactory.createClient()中使用的client.login()不能为空...
    • 好吧,我相信证书只是为了验证(信任)SSL连接;我不相信它用于识别用户(即使使用 sftp 公钥/私钥对,您也需要用户名;使用私钥而不是密码)。
    • @GaryRussell 非常感谢。我只是需要一个提示。我会试试的。
    • @GaryRussell - 我试过了,但没用。大多数实现都需要密码。
    猜你喜欢
    • 2019-07-20
    • 2018-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-22
    • 2013-02-28
    相关资源
    最近更新 更多