Version
2.8.0
Bug description
I overwrote the authenticate function of the PublickeyAuthenticator.java and registered it with the ssh server.
sshServer.setPublickeyAuthenticator(publicKeyAuth);
But when the client provides the key and certificate, MINA SSHD displays an error:
2024-12-25 17:29:30.882 sshd-SshServer[53600a30](port=2222)-nio2-thread-5 WARN org.apache.sshd.server.session.ServerUserAuthService.warn - handleUserAuthRequestMessage(ServerSessionImpl[null@/127.0.0.1:56562]) Failed (InvalidKeyException) to authenticate using factory method=publickey: Supplied key (org.apache.sshd.common.config.keys.OpenSshCertificateImpl) is not a RSAPublicKey instance
After debugging, I found that the problem is that when MINA SSHD initializes the signature verifier of the public key, the public key passed in is of type OpenSshCertificateImpl, while Signature expects an RSAPublicKey object. Why does this problem occur? How can I solve it?
Actual behavior
I rewrote the initVerifier function in SignatureRSA.java and now I can login correctly.
Old initVerifier function:
public void initVerifier(SessionContext session, PublicKey key) throws Exception {
super.initVerifier(session, key);
RSAKey rsaKey = ValidateUtils.checkInstanceOf(key, RSAKey.class, "Not an RSA key");
verifierSignatureSize = getVerifierSignatureSize(rsaKey);
}
I overwrote the initVerifier function:
public void initVerifier(SessionContext session, PublicKey key) throws Exception {
if (key instanceof OpenSshCertificate){
super.initVerifier(session, ((OpenSshCertificate) key).getCertPubKey());
RSAKey rsaKey = ValidateUtils.checkInstanceOf(((OpenSshCertificate) key).getCertPubKey(), RSAKey.class, "Not an RSA key");
verifierSignatureSize = getVerifierSignatureSize(rsaKey);
}else {
super.initVerifier(session, key);
RSAKey rsaKey = ValidateUtils.checkInstanceOf(key, RSAKey.class, "Not an RSA key");
verifierSignatureSize = getVerifierSignatureSize(rsaKey);
}
}
I am still curious as to why this happens? And whether there are any hidden dangers in my modification.
`
Relevant log output
No response
Other information
No response
Version
2.8.0
Bug description
I overwrote the authenticate function of the PublickeyAuthenticator.java and registered it with the ssh server.
But when the client provides the key and certificate, MINA SSHD displays an error:
After debugging, I found that the problem is that when MINA SSHD initializes the signature verifier of the public key, the public key passed in is of type OpenSshCertificateImpl, while Signature expects an RSAPublicKey object. Why does this problem occur? How can I solve it?
Actual behavior
I rewrote the initVerifier function in SignatureRSA.java and now I can login correctly.
Old initVerifier function:
I overwrote the initVerifier function:
I am still curious as to why this happens? And whether there are any hidden dangers in my modification.
`
Relevant log output
No response
Other information
No response