Spring FTP 没有 TLS 的客户端连接
Spring FTP Client connection without TLS
我正在努力创建与 spring ftpSessionFactory 的 ftp 连接。
在我的项目中,我使用 xml 配置与 TLS 建立 ftp 连接(有效):
<bean id="ftpSessionFactory"
class="org.springframework.integration.ftp.session.DefaultFtpsSessionFactory">
<property name="host" value="#{configurationService.configuration.getProperty('file.transfer.server.host')}" />
<property name="port" value="#{configurationService.configuration.getProperty('file.transfer.server.port')}" />
<property name="username" value="#{configurationService.configuration.getProperty('file.transfer.server.user')}" />
<property name="password" value="#{configurationService.configuration.getProperty('file.transfer.server.password')}" />
<property name="clientMode" value="2"/>
<property name="fileType" value="2"/>
<property name="useClientMode" value="true"/>
<property name="keyManager" ref="keyManager"/>
<property name="protocol" value="TLS"/>
<property name="trustManager" ref="trustManager"/>
<property name="prot" value="P"/>
<property name="needClientAuth" value="true"/>
<property name="sessionCreation" value="true"/>
<property name="implicit" value="false"/>
</bean>
现在我需要第二个连接,但没有 TLS(不要问 :D)。为此,我只是替换了 Java:
中的字段
ftpSessionFactory.setHost(host);
ftpSessionFactory.setPort(port);
ftpSessionFactory.setUsername(username);
ftpSessionFactory.setPassword(password);
ftpSessionFactory.setProtocol(StringUtils.isNoneEmpty(protocol) ? protocol : null); // <-- null for no TLS
但这给了我这个错误:javax.net.ssl.SSLException: 500 AUTH: unknown command
。
然后我尝试了硬编码方式(有效):
FTPClient f = new FTPClient();
f.connect(host);
f.login(username, password);
现在我的问题是:
我如何修改 xml 部分(我猜是 setter)以便它对两者都有效?
使用 DefaultFtpSessionFactory
代替 DefaultFtpsSessionFactory
。
我正在努力创建与 spring ftpSessionFactory 的 ftp 连接。
在我的项目中,我使用 xml 配置与 TLS 建立 ftp 连接(有效):
<bean id="ftpSessionFactory"
class="org.springframework.integration.ftp.session.DefaultFtpsSessionFactory">
<property name="host" value="#{configurationService.configuration.getProperty('file.transfer.server.host')}" />
<property name="port" value="#{configurationService.configuration.getProperty('file.transfer.server.port')}" />
<property name="username" value="#{configurationService.configuration.getProperty('file.transfer.server.user')}" />
<property name="password" value="#{configurationService.configuration.getProperty('file.transfer.server.password')}" />
<property name="clientMode" value="2"/>
<property name="fileType" value="2"/>
<property name="useClientMode" value="true"/>
<property name="keyManager" ref="keyManager"/>
<property name="protocol" value="TLS"/>
<property name="trustManager" ref="trustManager"/>
<property name="prot" value="P"/>
<property name="needClientAuth" value="true"/>
<property name="sessionCreation" value="true"/>
<property name="implicit" value="false"/>
</bean>
现在我需要第二个连接,但没有 TLS(不要问 :D)。为此,我只是替换了 Java:
中的字段ftpSessionFactory.setHost(host);
ftpSessionFactory.setPort(port);
ftpSessionFactory.setUsername(username);
ftpSessionFactory.setPassword(password);
ftpSessionFactory.setProtocol(StringUtils.isNoneEmpty(protocol) ? protocol : null); // <-- null for no TLS
但这给了我这个错误:javax.net.ssl.SSLException: 500 AUTH: unknown command
。
然后我尝试了硬编码方式(有效):
FTPClient f = new FTPClient();
f.connect(host);
f.login(username, password);
现在我的问题是:
我如何修改 xml 部分(我猜是 setter)以便它对两者都有效?
使用 DefaultFtpSessionFactory
代替 DefaultFtpsSessionFactory
。