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/09/07 09:54:26 UTC

[GitHub] [hbase] anmolnar commented on a diff in pull request #4724: HBASE-27280 Add mutual authentication support to TLS

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


##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -80,6 +80,13 @@ public final class X509Util {
   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_CONFIG_VERIFY_CLIENT_HOSTNAMES =
+    CONFIG_PREFIX + "verify.client.hostnames";
+  public static final String TLS_CONFIG_VERIFY_SERVER_HOSTNAMES =
+    CONFIG_PREFIX + "verify.server.hostnames";
+
+  public static final String TLS_CONFIG_CLIENT_AUTH_MODE = CONFIG_PREFIX + "client.auth.mode";

Review Comment:
   nit: the "CONFIG" word is not part of other property constants, so it's not consistent atm.



##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/HBaseTrustManager.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.io.crypto.tls;
+
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.X509ExtendedTrustManager;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A custom TrustManager that supports hostname verification We attempt to perform verification
+ * using just the IP address first and if that fails will attempt to perform a reverse DNS lookup
+ * and verify using the hostname. This file has been copied from the Apache ZooKeeper project.
+ * @see <a href=
+ *      "https://github.com/apache/zookeeper/blob/c74658d398cdc1d207aa296cb6e20de00faec03e/zookeeper-server/src/main/java/org/apache/zookeeper/common/ZKTrustManager.java">Base
+ *      revision</a>
+ */
+@InterfaceAudience.Private
+public class HBaseTrustManager extends X509ExtendedTrustManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(HBaseTrustManager.class);
+
+  private final X509ExtendedTrustManager x509ExtendedTrustManager;
+  private final boolean serverHostnameVerificationEnabled;
+  private final boolean clientHostnameVerificationEnabled;
+
+  private final HBaseHostnameVerifier hostnameVerifier;
+
+  /**
+   * Instantiate a new ZKTrustManager.

Review Comment:
   `HBaseTrustManager`



##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -80,6 +80,13 @@ public final class X509Util {
   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_CONFIG_VERIFY_CLIENT_HOSTNAMES =
+    CONFIG_PREFIX + "verify.client.hostnames";
+  public static final String TLS_CONFIG_VERIFY_SERVER_HOSTNAMES =
+    CONFIG_PREFIX + "verify.server.hostnames";

Review Comment:
   nit: I think these properties would be better in singular, not plural. It's possible to add multiple subject alternative names to certificates, but the verification effectively happens against a single, resolved hostname/ip address.



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