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_r410042133
 
 

 ##########
 File path: 
sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
 ##########
 @@ -367,9 +382,26 @@ protected String 
resolveAvailableSignaturesProposal(FactoryManager proposedManag
 
         KeyPairProvider kpp = getKeyPairProvider();
         boolean debugEnabled = log.isDebugEnabled();
-        Iterable<String> provided;
+        Set<String> provided = null;
         try {
-            provided = (kpp == null) ? null : kpp.getKeyTypes(this);
+            if (kpp != null) {
+                provided = 
StreamSupport.stream(kpp.getKeyTypes(this).spliterator(), false)
+                    .collect(Collectors.toSet());
+
+                HostKeyCertificateProvider hostKeyCertificateProvider = 
getHostKeyCertificateProvider();
+                if (hostKeyCertificateProvider != null) {
+                    Iterable<OpenSshCertificate> certificates = 
hostKeyCertificateProvider.loadCertificates(this);
+                    for (OpenSshCertificate certificate : certificates) {
+                        // Add the certificate alg only if the corresponding 
keyPair type is available
+                        if (provided.contains(certificate.getRawKeyType())) {
+                            provided.add(certificate.getKeyType());
+                        } else {
 
 Review comment:
   The idea is that we do not want to iterate over the returned key types until 
really necessary - SSHD-860 implements "lazy" iterators that load keys only 
when 'next()' is called.  Therefore 
   ```java
   StreamSupport.stream(kpp.getKeyTypes(this).spliterator(), 
false).collect(Collectors.toSet());
   ```
   violates this "laziness" since it collects all the key types - something we 
wanted to avoid doing in SSHD-860

----------------------------------------------------------------
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]

Reply via email to