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_r409645833
##########
File path: sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
##########
@@ -154,4 +168,54 @@ public boolean next(int cmd, Buffer buffer) throws
Exception {
return true;
}
+
+ protected void verifyCertificate(Session session, OpenSshCertificate
openSshKey) throws Exception {
+ 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,
+ "KeyExchange CA signature verification failed for key
type=" + keyAlg);
+ }
+
+ if (openSshKey.getType() != OpenSshCertificate.SSH_CERT_TYPE_HOST) {
+ throw new
SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ "KeyExchange signature verification failed, not a host key
(2): "
+ + openSshKey.getType());
+ }
+
+ long now = System.currentTimeMillis() / 1000;
+ if (now <= openSshKey.getValidAfter() || now >=
openSshKey.getValidBefore()) {
Review comment:
This condition seems wrong - shouldn't it be the other way around ? I.e., it
is valid if `before <= now <= after`
----------------------------------------------------------------
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]