Unable to connect with a key from the `AndroidKeyStore`
- Dominant language
- Java
- Stars
- 2.7k
- Forks
- 620
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 11
Description
Hello, I tried using the lib to connect by using a key generated with the `AndroidKeyStore` in an Android application. It seems to not work as I'm getting the following exception.
```java
net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:231)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:346)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:365)
Caused by: net.schmizz.sshj.userauth.UserAuthException: Could not create signature instance for unknown key
at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putSig(KeyedAuthMethod.java:67)
at net.schmizz.sshj.userauth.method.AuthPublickey.sendSignedReq(AuthPublickey.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.handle(AuthPublickey.java:45)
at net.schmizz.sshj.userauth.UserAuthImpl.handle(UserAuthImpl.java:142)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:500)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:102)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:170)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
```
All I can guess is the following line tries list the factories of the keys.
https://github.com/hierynomus/sshj/blob/db48ff85c05d2d85018e32e3631d0a3161d05b82/src/main/java/net/schmizz/sshj/userauth/method/KeyedAuthMethod.java#L65
But when the key instance was created, it couldn't check the type of the key because it got fetched in the raw data of the key.
The problem with the [Android Key Store][1], like any other `HSM`, is that you can't directly access the key, you can only ask it to perform operations on data. So checking the key type or doing actions by using its encoded data cannot be performed. Tho, I don't see (yet) where in `SSHJ`'s code it is performed.
Would it be possible to make those operations performed like shown in the link when dealing with a `KeyPair`?
[1]: https://developer.android.com/training/articles/keystore
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.