Jelajahi Sumber

fix: allow non-ca certificates during root_ca only mode

Jason Rivard 5 tahun lalu
induk
melakukan
54dc739408
1 mengubah file dengan 13 tambahan dan 1 penghapusan
  1. 13 1
      server/src/main/java/password/pwm/util/secure/X509Utils.java

+ 13 - 1
server/src/main/java/password/pwm/util/secure/X509Utils.java

@@ -544,12 +544,24 @@ public abstract class X509Utils
     {
     {
         for ( final X509Certificate certificate : certificates )
         for ( final X509Certificate certificate : certificates )
         {
         {
-            final boolean[] keyUsages = certificate.getKeyUsage();
             if ( certIsRootCA( certificate ) )
             if ( certIsRootCA( certificate ) )
             {
             {
                 return Collections.singletonList( certificate );
                 return Collections.singletonList( certificate );
             }
             }
         }
         }
+
+        if ( certificates.size() == 1 )
+        {
+            LOGGER.debug( () -> "ServerCertReader: treating single certificate as ROOT CA certificate: "
+                    + X509Utils.makeDebugText(  certificates.iterator().next() ) );
+            return Collections.unmodifiableList( certificates );
+        }
+
+        if ( !certificates.isEmpty() )
+        {
+            LOGGER.debug( () -> "ServerCertReader: no certificates in read certificate chain are detected as CA cert" );
+        }
+
         return Collections.emptyList();
         return Collections.emptyList();
     }
     }