Skip to content

DefaultSftpSessionFactory file resolving inconsistency #3211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
m-terra opened this issue Mar 9, 2020 · 3 comments · Fixed by #3212
Closed

DefaultSftpSessionFactory file resolving inconsistency #3211

m-terra opened this issue Mar 9, 2020 · 3 comments · Fixed by #3212

Comments

@m-terra
Copy link
Contributor

m-terra commented Mar 9, 2020

Using Spring Boot 2.2.4 with Spring Integration SFTP 5.2.3

org.springframework.integration.sftp.session.DefaultSftpSessionFactory

Actual Behavior:
Property privateKey expects the prefix file: since it is resolved by Spring.
Property knownHosts does not work with file: prefix since it is passed directly to JCraft.

Expected Behavior:
Both properties privateKey and knownHosts work with file: prefix.

@artembilan
Copy link
Member

There is an API like this:

 /**
   * Sets the instance of <code>KnownHosts</code> generated with
   * <code>stream</code>.
   *
   * @param stream the instance of InputStream from known_hosts file.
   *
   * @throws JSchException
   *         if an I/O error occurs.
   *
   * @see com.jcraft.jsch.KnownHosts
   */
  public void setKnownHosts(InputStream stream) throws JSchException{ 

So, we indeed can have that knownHosts as a Resource as well and propagate its InputStream into JSch properly.

Feel free to contribute the fix, @andybaer !

Thanks for pointing this out!

@artembilan
Copy link
Member

@andybaer ,

Since you have not answered yet, but we are going to release tomorrow, I take an issue and will provide a Pull Request shortly.

@artembilan artembilan self-assigned this Mar 10, 2020
artembilan added a commit to artembilan/spring-integration that referenced this issue Mar 10, 2020
Fixes spring-projects#3211

* Add `DefaultSftpSessionFactory.setKnownHosts(Resource)` to
allow to configure externally any resource for file with known_hosts content
* Deprecate an existing method in favor of new one
* The new method makes it aligned with the `setPrivateKey(Resource)`
* Fix tests do not use a deprecated method any more

**Cherry-pick to 5.2.x**
garyrussell pushed a commit that referenced this issue Mar 10, 2020
* GH-3211: Add DefSftpSF.setKnownHosts(Resource)

Fixes #3211

* Add `DefaultSftpSessionFactory.setKnownHosts(Resource)` to
allow to configure externally any resource for file with known_hosts content
* Deprecate an existing method in favor of new one
* The new method makes it aligned with the `setPrivateKey(Resource)`
* Fix tests do not use a deprecated method any more

**Cherry-pick to 5.2.x**

* * Rename to `setKnownHostsResource()` to avoid XML parser confusion
* Change `sftp.adoc` to reflect a new property
@m-terra
Copy link
Contributor Author

m-terra commented Mar 13, 2020

@artembilan

Sorry for the late answer. I tried to get the build working behind the corporate proxy but failed to do so.

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants