FliegenKLATSCH 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_r409752593
 
 

 ##########
 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:
   >A certificate is considered valid if:
   The <= should be a strict <, but with the negation it should be correct 
besides this.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to