devvthedev commented on issue #532: URL: https://github.com/apache/mina-sshd/issues/532#issuecomment-2315531580
Hi @tomaswolf Thanks for getting back to me. I've tried what you suggested: ``` String privateKeyContent = "private key contents" String passphrase "private key passphrase contents" Iterable<KeyPair> keyPairs = SecurityUtils.loadKeyPairIdentities(null, null, new ByteArrayInputStream(privateKeyContent.getBytes()), (session, resourceKey, retryIndex) -> passphrase); SshdSessionFactory sshSessionFactory = new SshdSessionFactoryBuilder() .setPreferredAuthentications("publickey") .setDefaultKeysProvider(ignoredSshDirBecauseWeUseAnInMemorySetOfKeyPairs -> keyPairs) .setHomeDirectory(directory) // Need to set despite setting ConfigStoreFactory and ServerKeyDatabase up .setSshDirectory(directory) // Need to set despite setting ConfigStoreFactory and ServerKeyDatabase up .setConfigStoreFactory((ignoredHomeDir, ignoredConfigFile, ignoredLocalUserName) -> null) .setServerKeyDatabase((ignoredHomeDir, ignoredSshDir) -> new ServerKeyDatabase() { @Override public List<PublicKey> lookup(String connectAddress, InetSocketAddress remoteAddress, Configuration config) { return Collections.emptyList(); } @Override public boolean accept(String connectAddress, InetSocketAddress remoteAddress, PublicKey serverKey, Configuration config, CredentialsProvider provider) { // Work out whether to accept the server key or not // example: accept all server keys return true; } }) .build(null); ``` When the `build` method is invoked, it then sets the following on the SshdSessionFactory: ``` factory.setHomeDirectory(homeDirectory); factory.setSshDirectory(sshDirectory); ``` <br> The method signatures both specify `@NonNull` e.g. ``` public void setHomeDirectory(@NonNull File homeDir) { ... } ``` and ``` public void setSshDirectory(@NonNull File sshDir) { ... } ``` https://github.com/eclipse-jgit/jgit/blob/master/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSessionFactory.java#L312-L324 I believe if these were nullable that would alleviate this? What do you think? I will open a Bug issue in JGit describing this in more detail. Thanks -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For additional commands, e-mail: dev-h...@mina.apache.org