This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit 31c07d7c6709bd46864bfff20d11b110d6da714f
Author: Lyor Goldstein <lgoldst...@apache.org>
AuthorDate: Wed Jul 22 11:21:01 2020 +0300

    [SSHD-1040] Return NULL host key from AbstractServerSession if KEX not yet 
completed
---
 .../java/org/apache/sshd/server/session/AbstractServerSession.java    | 4 ++++
 1 file changed, 4 insertions(+)

diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
 
b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
index bf95597..fb131d9 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
@@ -528,6 +528,10 @@ public abstract class AbstractServerSession extends 
AbstractSession implements S
     public KeyPair getHostKey() {
         String proposedKey = 
getNegotiatedKexParameter(KexProposalOption.SERVERKEYS);
         String keyType = KeyUtils.getCanonicalKeyType(proposedKey);
+        if (GenericUtils.isEmpty(keyType)) {
+            return null;    // OK if not negotiated yet
+        }
+
         KeyPairProvider provider = 
Objects.requireNonNull(getKeyPairProvider(), "No host keys provider");
         try {
             HostKeyCertificateProvider hostKeyCertificateProvider = 
getHostKeyCertificateProvider();

Reply via email to