You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "anmolnar (via GitHub)" <gi...@apache.org> on 2023/08/24 15:08:48 UTC

[GitHub] [hbase] anmolnar commented on a diff in pull request #5363: HBASE-28008 Add support for netty tcnative

anmolnar commented on code in PR #5363:
URL: https://github.com/apache/hbase/pull/5363#discussion_r1304464029


##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -83,9 +88,10 @@ public final class X509Util {
   public static final String TLS_CONFIG_OCSP = CONFIG_PREFIX + "ocsp";
   public static final String TLS_CONFIG_REVERSE_DNS_LOOKUP_ENABLED =
     CONFIG_PREFIX + "host-verification.reverse-dns.enabled";
-  private static final String TLS_ENABLED_PROTOCOLS = CONFIG_PREFIX + "enabledProtocols";
-  private static final String TLS_CIPHER_SUITES = CONFIG_PREFIX + "ciphersuites";
+  public static final String TLS_ENABLED_PROTOCOLS = CONFIG_PREFIX + "enabledProtocols";
+  public static final String TLS_CIPHER_SUITES = CONFIG_PREFIX + "ciphersuites";
   public static final String TLS_CERT_RELOAD = CONFIG_PREFIX + "certReload";
+  public static final String TLS_USE_OPENSSL = CONFIG_PREFIX + "useOpenSsl";

Review Comment:
   Why do you make these public? For consistency?



##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -234,11 +272,23 @@ public static SslContext createSslContextForClient(Configuration config)
 
     sslContextBuilder.enableOcsp(sslOcspEnabled);
     sslContextBuilder.protocols(getEnabledProtocols(config));
-    sslContextBuilder.ciphers(Arrays.asList(getCipherSuites(config)));
+    sslContextBuilder.ciphers(Arrays.asList(getCipherSuites(config, useOpenSsl)));
 
     return sslContextBuilder.build();
   }
 
+  private static boolean configureOpenSslIfAvailable(SslContextBuilder sslContextBuilder,
+    Configuration conf) {
+    if (OpenSsl.isAvailable() && conf.getBoolean(TLS_USE_OPENSSL, true)) {
+      LOG.debug("Using netty-tcnative to accelerate TLS handling");
+      sslContextBuilder.sslProvider(SslProvider.OPENSSL);
+      return true;
+    } else {
+      sslContextBuilder.sslProvider(SslProvider.JDK);

Review Comment:
   Might be useful to explicitly indicate in a warning message if user wants to use OpenSSL, but it's not available so HBase falls back to JDK. Netty is able to deal with this and log it if you just set the sslProvider to OPENSSL without making sure it's available.
   
   ZooKeeper does the same btw: instead of relying on Netty's default, the ssl provider is always set explictly.



##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -131,6 +137,34 @@ private static String[] getCBCCiphers() {
   private static final String[] DEFAULT_CIPHERS_JAVA9 =
     ObjectArrays.concat(getGCMCiphers(), getCBCCiphers(), String.class);
 
+  private static final String[] DEFAULT_CIPHERS_OPENSSL = getOpenSslFilteredDefaultCiphers();
+
+  /**
+   * Not all of our default ciphers are available in OpenSSL. Takes our default cipher lists and
+   * filters them to only those available in OpenSsl. Does GCM first, then CBC because GCM tends to
+   * be better and faster, and we don't need to worry about the java8 vs 9 performance issue if
+   * OpenSSL is handling it.
+   */

Review Comment:
   Nice approach. In ZooKeeper we simply don't set default cipher suites just let OpenSSL to decide. User can still override them though.



-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org