adoroszlai commented on code in PR #10111:
URL: https://github.com/apache/ozone/pull/10111#discussion_r3129967187


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/BaseHttpServer.java:
##########
@@ -386,7 +386,9 @@ public static HttpServer2.Builder 
loadSslConfToHttpServerBuilder(
             sslConf.get(HddsConfigKeys.HDDS_HTTP_SERVER_TRUSTSTORE_TYPE,
                 HddsConfigKeys.HDDS_HTTP_SERVER_TRUSTSTORE_TYPE_DEFAULT))
         .excludeCiphers(
-            sslConf.get("ssl.server.exclude.cipher.list"));
+            sslConf.get("ssl.server.exclude.cipher.list"))
+        .includeCiphers(
+            sslConf.get("ssl.server.include.cipher.list"));

Review Comment:
   nit: add before `.excludeCiphers` to reduce change (due to moving around `;`)
   
   Also, I think these can use constants 
`SSLFactory.SSL_SERVER_EXCLUDE_CIPHER_LIST` and 
`SSLFactory.SSL_SERVER_INCLUDE_CIPHER_LIST`, since `HttpServer2` already does.



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/HttpServer2.java:
##########
@@ -565,17 +573,59 @@ private ServerConnector createHttpsChannelConnector(
           sslContextFactory.setTrustStorePassword(trustStorePassword);
         }
       }
-      if (null != excludeCiphers && !excludeCiphers.isEmpty()) {
+      if (excludeCiphers != null && !excludeCiphers.isEmpty()) {

Review Comment:
   nit: unnecessary change



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/HttpServer2.java:
##########
@@ -565,17 +573,59 @@ private ServerConnector createHttpsChannelConnector(
           sslContextFactory.setTrustStorePassword(trustStorePassword);
         }
       }
-      if (null != excludeCiphers && !excludeCiphers.isEmpty()) {
+      if (excludeCiphers != null && !excludeCiphers.isEmpty()) {
         sslContextFactory.setExcludeCipherSuites(
             StringUtils.getTrimmedStrings(excludeCiphers));
         LOG.info("Excluded Cipher List: {}", excludeCiphers);
       }
 
+      if (includeCiphers != null && !includeCiphers.isEmpty()) {
+        sslContextFactory.setIncludeCipherSuites(
+            StringUtils.getTrimmedStrings(includeCiphers));
+        LOG.info("Included Cipher List: {}", includeCiphers);
+      }
+
+      setEnabledProtocols(sslContextFactory);
+
       conn.addFirstConnectionFactory(new 
SslConnectionFactory(sslContextFactory,
           HttpVersion.HTTP_1_1.asString()));
 
       return conn;
     }
+
+    private void setEnabledProtocols(
+        SslContextFactory sslContextFactory) {
+      String enabledProtocols = conf.get(
+          SSLFactory.SSL_ENABLED_PROTOCOLS_KEY,
+          SSLFactory.SSL_ENABLED_PROTOCOLS_DEFAULT);
+      if (!enabledProtocols.equals(
+          SSLFactory.SSL_ENABLED_PROTOCOLS_DEFAULT)) {
+        String[] jettyExcludedProtocols =
+            sslContextFactory.getExcludeProtocols();
+        String[] enabledProtocolsArray =
+            StringUtils.getTrimmedStrings(enabledProtocols);
+        List<String> enabledProtocolsList =
+            Arrays.asList(enabledProtocolsArray);
+
+        List<String> resetExcludedProtocols = new ArrayList<>();
+        for (String jettyExcludedProtocol : jettyExcludedProtocols) {
+          if (!enabledProtocolsList.contains(jettyExcludedProtocol)) {
+            resetExcludedProtocols.add(jettyExcludedProtocol);
+          } else {
+            LOG.debug("Removed {} from exclude protocol list",
+                jettyExcludedProtocol);
+          }
+        }
+
+        sslContextFactory.setExcludeProtocols(
+            resetExcludedProtocols.toArray(new String[0]));
+        LOG.info("Reset exclude protocol list: {}",
+            resetExcludedProtocols);

Review Comment:
   nit: line wraps are unnecesary



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/HttpServer2.java:
##########
@@ -565,17 +573,59 @@ private ServerConnector createHttpsChannelConnector(
           sslContextFactory.setTrustStorePassword(trustStorePassword);
         }
       }
-      if (null != excludeCiphers && !excludeCiphers.isEmpty()) {
+      if (excludeCiphers != null && !excludeCiphers.isEmpty()) {
         sslContextFactory.setExcludeCipherSuites(
             StringUtils.getTrimmedStrings(excludeCiphers));
         LOG.info("Excluded Cipher List: {}", excludeCiphers);
       }
 
+      if (includeCiphers != null && !includeCiphers.isEmpty()) {
+        sslContextFactory.setIncludeCipherSuites(
+            StringUtils.getTrimmedStrings(includeCiphers));
+        LOG.info("Included Cipher List: {}", includeCiphers);
+      }
+
+      setEnabledProtocols(sslContextFactory);
+
       conn.addFirstConnectionFactory(new 
SslConnectionFactory(sslContextFactory,
           HttpVersion.HTTP_1_1.asString()));
 
       return conn;
     }
+
+    private void setEnabledProtocols(
+        SslContextFactory sslContextFactory) {
+      String enabledProtocols = conf.get(
+          SSLFactory.SSL_ENABLED_PROTOCOLS_KEY,
+          SSLFactory.SSL_ENABLED_PROTOCOLS_DEFAULT);
+      if (!enabledProtocols.equals(
+          SSLFactory.SSL_ENABLED_PROTOCOLS_DEFAULT)) {
+        String[] jettyExcludedProtocols =
+            sslContextFactory.getExcludeProtocols();
+        String[] enabledProtocolsArray =
+            StringUtils.getTrimmedStrings(enabledProtocols);
+        List<String> enabledProtocolsList =
+            Arrays.asList(enabledProtocolsArray);
+
+        List<String> resetExcludedProtocols = new ArrayList<>();
+        for (String jettyExcludedProtocol : jettyExcludedProtocols) {
+          if (!enabledProtocolsList.contains(jettyExcludedProtocol)) {
+            resetExcludedProtocols.add(jettyExcludedProtocol);
+          } else {
+            LOG.debug("Removed {} from exclude protocol list",
+                jettyExcludedProtocol);
+          }
+        }

Review Comment:
   Can be simplified?
   
   ```java
   List<String> resetExcludedProtocols = new 
ArrayList<>(jettyExcludedProtocols);
   resetExcludedProtocols.removeAll(enabledProtocolsList);
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to