You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Daniel Hammer (Jira)" <ji...@apache.org> on 2022/09/23 08:54:00 UTC
[jira] [Created] (SSHD-1297) Load public key from file
Daniel Hammer created SSHD-1297:
-----------------------------------
Summary: Load public key from file
Key: SSHD-1297
URL: https://issues.apache.org/jira/browse/SSHD-1297
Project: MINA SSHD
Issue Type: Bug
Affects Versions: 2.9.1
Reporter: Daniel Hammer
Hi SSHD gurus,
I'm attempting to utilize {{org.apache.sshd.common.util.buffer.ByteArrayBuffer}} to load a {{java.security.PublicKey}} in-order to subsequently register the public key in a {{{}org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator{}}}.
Ie. the idea is something like this
{code:java}
PublicKey myPublicKey;
try (InputStream is = new FileInputStream("/home/my-user/tmp/test_rsa_key.pub")) {
ByteArrayBuffer buffer = new ByteArrayBuffer(org.apache.sshd.common.util.io.IoUtils.IoUtils.toByteArray(is));
myPublicKey = buffer.getPublicKey(); // -> OutOfMemoryError: Java heap space ..?
// myPublicKey = buffer.getRawPublicKey(); // -> Underflow ..?
}
ServerBuilder.builder()
.publickeyAuthenticator(new KeySetPublickeyAuthenticator("my id", List.of(myPublicKey)))
.build();
{code}
Resulting in the below exceptions, caused by internal guarding in {{ByteArrayBuffer}} before the {{ByteArrayBuffer.data}} would be processed.
{{{}getPublicKey(){}}}:
{code:java}
java.lang.OutOfMemoryError: Java heap space
at org.apache.sshd.common.util.buffer.ByteArrayBuffer.ensureCapacity(ByteArrayBuffer.java:277)
at org.apache.sshd.common.util.buffer.Buffer.ensureCapacity(Buffer.java:1105)
at org.apache.sshd.common.util.buffer.ByteArrayBuffer.wpos(ByteArrayBuffer.java:139)
at org.apache.sshd.common.util.buffer.Buffer.getPublicKey(Buffer.java:521)
at org.apache.sshd.common.util.buffer.Buffer.getPublicKey(Buffer.java:505)
{code}
{{{}getRawPublicKey(){}}}:
{code:java}
org.apache.sshd.common.util.buffer.BufferException: Underflow: requested=1936943149, available=737
at app//org.apache.sshd.common.util.buffer.Buffer.ensureAvailable(Buffer.java:640)
at app//org.apache.sshd.common.util.buffer.ByteArrayBuffer.getString(ByteArrayBuffer.java:241)
at app//org.apache.sshd.common.util.buffer.Buffer.getString(Buffer.java:309)
at app//org.apache.sshd.common.util.buffer.Buffer.getRawPublicKey(Buffer.java:541)
at app//org.apache.sshd.common.util.buffer.Buffer.getRawPublicKey(Buffer.java:530)
{code}
Seemingly my approach is incompatible with the available logic, unfortunately I've been unable to uncover documentation or Javadoc that could aid.
So as a last resort I'm turning to you gurus, in hopes of enlightenment (+ perhaps a PR guiding future developers in the desired direction via documentation / Javadoc).
Thanks in advance 🙏
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org