robtimus/sftp-fs

Creating Identity from byte array instead of file

wrosenuance opened this issue · 4 comments

I am trying to create an Identity from a byte array rather than a file, as our security requirements are that the identities are fetched from Azure Key Vault and not local filesystems.

There does not appear to be a way to construct an Identity without using files, which seems to rule out the use of that class, leaving implementing the JSch IdentityRepository interface as the only option. However, the implementations of that interface rely on access to the JSch instance, which is not available when the SFTP environment is being created, and doesn't seem to be injected.

Is there a way around this?

I noticed that JSch has two more addIdentity methods that aren't exposed. I'll add method Identity.fromData(String name, byte[] privateKey, byte[] publicKey, byte[] passphrase) which delegates to the matching JSch.addIdentity method. This should allow you to pass the private and public keys as byte arrays.

Thank you!

I've just released version 1.4 which include this new method. I've added tests to make sure this method, as well as the other Identity factory methods, actually produce something that can be used to login.

Thank you! Looks great!