2
votes

I am trying to use org.springframework.integration.ftp.session.DefaultFtpsSessionFactory for my FTPS client, but I do not have userId or Password. I have *.cer file. How do I create instance of session factory using certificate. So far I have looked at

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

I just couldn't find any straight forward usage to using certificate while creating ftpsclient.

1

1 Answers

0
votes

I've not done it, but I think you will have to create a subclass of DefaultFtpsSessionFactory, override createClientInstance() to use one of the FTPSClient constructors that takes an SSLContext.

You would have to initialize the SSL context with a KeyManager that has been initialized from a keystore that contains the certificate.

spring-integration-ip has some code that does this for TCP connections.