lgoldstein commented on a change in pull request #119: Add support for openssh
host key certificates
URL: https://github.com/apache/mina-sshd/pull/119#discussion_r408350789
##########
File path: sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
##########
@@ -124,10 +129,67 @@ public boolean next(int cmd, Buffer buffer) throws
Exception {
buffer = new ByteArrayBuffer(k_s);
serverKey = buffer.getRawPublicKey();
- String keyAlg = KeyUtils.getKeyType(serverKey);
+ PublicKey serverPublicHostKey = serverKey;
+
+ OpenSshCertificate openSshKey = null;
+ if (serverKey instanceof OpenSshCertificate) {
+ openSshKey = (OpenSshCertificate) serverKey;
+ serverPublicHostKey = openSshKey.getServerHostKey();
+
+ // verify signature
+ PublicKey signatureKey = openSshKey.getCaPubKey();
+ String keyAlg = KeyUtils.getKeyType(signatureKey);
+ Signature verif = ValidateUtils.checkNotNull(
+ NamedFactory.create(session.getSignatureFactories(),
keyAlg),
+ "No verifier located for algorithm=%s", keyAlg);
+ verif.initVerifier(session, signatureKey);
+ verif.update(session, openSshKey.getMessage());
+ if (!verif.verify(session, openSshKey.getSignature())) {
+ throw new
SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
Review comment:
Let's try and find a way to move this large block of code to some method,,,
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]