You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2022/08/02 08:02:12 UTC

[GitHub] [hbase] meszibalu commented on a diff in pull request #4666: HBASE-26666 Add native TLS encryption support to RPC server/client

meszibalu commented on code in PR #4666:
URL: https://github.com/apache/hbase/pull/4666#discussion_r935198219


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java:
##########
@@ -214,4 +227,29 @@ public int getNumOpenConnections() {
     // allChannels also contains the server channel, so exclude that from the count.
     return channelsCount > 0 ? channelsCount - 1 : channelsCount;
   }
+
+  private void initSSL(ChannelPipeline p, boolean supportPlaintext)
+    throws X509Exception, SSLException {
+    SslContext nettySslContext = getSslContext();
+
+    if (supportPlaintext) {
+      p.addLast("ssl", new OptionalSslHandler(nettySslContext));
+      LOG.debug("Dual mode SSL handler added for channel: {}", p.channel());
+    } else {
+      p.addLast("ssl", nettySslContext.newHandler(p.channel().alloc()));
+      LOG.debug("SSL handler added for channel: {}", p.channel());
+    }
+  }
+
+  private SslContext getSslContext() throws X509Exception, SSLException {
+    SslContext result = sslContextForServer.get();
+    if (result == null) {
+      result = X509Util.createSslContextForServer(conf);
+      if (!sslContextForServer.compareAndSet(null, result)) {
+        // lost the race, another thread already set the value
+        result = sslContextForServer.get();
+      }
+    }
+    return result;

Review Comment:
   If you create the context in `initSsl` then you don't have to lock, because it is called from the constructor.



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