You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "lucakovacs (via GitHub)" <gi...@apache.org> on 2026/09/18 10:48:13 UTC
[PR] HBASE-30387: Support SingleEKU certificates [hbase]
lucakovacs opened a new pull request, #8681:
URL: https://github.com/apache/hbase/pull/8681
(no comment)
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "petersomogyi (via GitHub)" <gi...@apache.org>.
petersomogyi commented on code in PR #8681:
URL: https://github.com/apache/hbase/pull/8681#discussion_r4094086064
##########
hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/tls/TestX509Util.java:
##########
@@ -375,4 +376,142 @@ public void testLoadPKCS12TrustStoreWithWrongPassword() {
});
}
+ // ---------------------------------------------------------------------------
+ // Role-scoped configuration resolution (single-EKU certificate support)
+ // ---------------------------------------------------------------------------
+
+ @TestTemplate
+ public void testResolveConfigPrefersRoleScopedOverLegacy() {
+ conf.set("test.role", "role-value");
+ conf.set("test.legacy", "legacy-value");
+ assertEquals("role-value",
+ X509Util.resolveConfig(conf, "test.role", "test.legacy", "default-value"));
+ }
+
+ @TestTemplate
+ public void testResolveConfigFallsBackToLegacyWhenRoleUnset() {
+ conf.unset("test.role");
+ conf.set("test.legacy", "legacy-value");
+ assertEquals("legacy-value",
+ X509Util.resolveConfig(conf, "test.role", "test.legacy", "default-value"));
+ }
+
+ @TestTemplate
+ public void testResolveConfigReturnsDefaultWhenBothUnset() {
+ conf.unset("test.role");
+ conf.unset("test.legacy");
+ assertEquals("default-value",
+ X509Util.resolveConfig(conf, "test.role", "test.legacy", "default-value"));
+ }
+
+ @TestTemplate
+ public void testResolvePasswordPrefersRoleScopedOverLegacy() throws Exception {
+ conf.set("test.role.password", "role-pw");
+ conf.set("test.legacy.password", "legacy-pw");
+ assertArrayEquals("role-pw".toCharArray(),
+ X509Util.resolvePassword(conf, "test.role.password", "test.legacy.password"));
+ }
+
+ @TestTemplate
+ public void testResolvePasswordFallsBackToLegacyWhenRoleUnset() throws Exception {
+ conf.unset("test.role.password");
+ conf.set("test.legacy.password", "legacy-pw");
+ assertArrayEquals("legacy-pw".toCharArray(),
+ X509Util.resolvePassword(conf, "test.role.password", "test.legacy.password"));
+ }
+
+ @TestTemplate
+ public void testResolvePasswordReturnsNullWhenBothUnset() throws Exception {
+ conf.unset("test.role.password");
+ conf.unset("test.legacy.password");
+ assertNull(X509Util.resolvePassword(conf, "test.role.password", "test.legacy.password"));
+ }
+
+ @TestTemplate
+ public void testCreateSSLContextForClientUsesRoleScopedKeystoreWhenSet() throws Exception {
+ // Move the legacy keystore values to the client-scoped keys and clear the legacy keys, so
+ // that a successful context build proves the client-scoped keys were consulted.
+ String location = conf.get(X509Util.TLS_CONFIG_KEYSTORE_LOCATION);
+ String password = conf.get(X509Util.TLS_CONFIG_KEYSTORE_PASSWORD);
+ String type = conf.get(X509Util.TLS_CONFIG_KEYSTORE_TYPE);
+ conf.set(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_LOCATION, location);
+ conf.set(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_PASSWORD, password);
+ conf.set(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_TYPE, type);
+ conf.unset(X509Util.TLS_CONFIG_KEYSTORE_LOCATION);
+ conf.unset(X509Util.TLS_CONFIG_KEYSTORE_PASSWORD);
+ conf.unset(X509Util.TLS_CONFIG_KEYSTORE_TYPE);
+
+ SslContext sslContext = X509Util.createSslContextForClient(conf);
+ ByteBufAllocator byteBufAllocatorMock = mock(ByteBufAllocator.class);
+ // Handshake would fail if the key manager weren't wired; smoke-test that engine creation works.
+ assertTrue(
+ sslContext.newEngine(byteBufAllocatorMock).getSSLParameters().getProtocols().length > 0);
+ }
+
+ @TestTemplate
+ public void testCreateSSLContextForClientFallsBackToLegacyKeystore() throws Exception {
+ // The base setUp() only sets the legacy TLS_CONFIG_KEYSTORE_* / TLS_CONFIG_TRUSTSTORE_* keys.
+ // The role-scoped keys are intentionally unset; the context must still build using the legacy
+ // values (backward-compat regression guard).
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_LOCATION);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_PASSWORD);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_TYPE);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_TRUSTSTORE_LOCATION);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_TRUSTSTORE_PASSWORD);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_TRUSTSTORE_TYPE);
+
+ SslContext sslContext = X509Util.createSslContextForClient(conf);
+ ByteBufAllocator byteBufAllocatorMock = mock(ByteBufAllocator.class);
+ assertTrue(
+ sslContext.newEngine(byteBufAllocatorMock).getSSLParameters().getProtocols().length > 0);
+ }
+
+ @TestTemplate
+ public void testCreateSSLContextForServerUsesRoleScopedKeystoreWhenSet() throws Exception {
+ String location = conf.get(X509Util.TLS_CONFIG_KEYSTORE_LOCATION);
+ String password = conf.get(X509Util.TLS_CONFIG_KEYSTORE_PASSWORD);
+ String type = conf.get(X509Util.TLS_CONFIG_KEYSTORE_TYPE);
+ conf.set(X509Util.TLS_CONFIG_SERVER_KEYSTORE_LOCATION, location);
+ conf.set(X509Util.TLS_CONFIG_SERVER_KEYSTORE_PASSWORD, password);
+ conf.set(X509Util.TLS_CONFIG_SERVER_KEYSTORE_TYPE, type);
+ conf.unset(X509Util.TLS_CONFIG_KEYSTORE_LOCATION);
+ conf.unset(X509Util.TLS_CONFIG_KEYSTORE_PASSWORD);
+ conf.unset(X509Util.TLS_CONFIG_KEYSTORE_TYPE);
+
+ SslContext sslContext = X509Util.createSslContextForServer(conf);
+ ByteBufAllocator byteBufAllocatorMock = mock(ByteBufAllocator.class);
+ assertTrue(
+ sslContext.newEngine(byteBufAllocatorMock).getSSLParameters().getProtocols().length > 0);
+ }
+
+ @TestTemplate
+ public void testCreateSSLContextForServerFallsBackToLegacyKeystore() throws Exception {
Review Comment:
Same comment as testCreateSSLContextForClientFallsBackToLegacyKeystore
##########
hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java:
##########
@@ -413,16 +423,58 @@ protected void setupHTTPServer() throws IOException {
httpsConfig.addCustomizer(new SecureRequestCustomizer());
SslContextFactory.Server sslCtxFactory = new SslContextFactory.Server();
- String keystore = conf.get(THRIFT_SSL_KEYSTORE_STORE_KEY);
+ // Prefer the role-scoped hbase.thrift.ssl.server.* keys, falling back to the historical
+ // unscoped hbase.thrift.ssl.* keys for backward compatibility with existing deployments.
+ String keystore = X509Util.resolveConfig(conf, THRIFT_SSL_SERVER_KEYSTORE_STORE_KEY,
+ THRIFT_SSL_KEYSTORE_STORE_KEY, null);
String password =
- HBaseConfiguration.getPassword(conf, THRIFT_SSL_KEYSTORE_PASSWORD_KEY, null);
+ HBaseConfiguration.getPassword(conf, THRIFT_SSL_SERVER_KEYSTORE_PASSWORD_KEY,
+ HBaseConfiguration.getPassword(conf, THRIFT_SSL_KEYSTORE_PASSWORD_KEY, null));
String keyPassword =
- HBaseConfiguration.getPassword(conf, THRIFT_SSL_KEYSTORE_KEYPASSWORD_KEY, password);
+ HBaseConfiguration.getPassword(conf, THRIFT_SSL_SERVER_KEYSTORE_KEYPASSWORD_KEY,
+ HBaseConfiguration.getPassword(conf, THRIFT_SSL_KEYSTORE_KEYPASSWORD_KEY, password));
sslCtxFactory.setKeyStorePath(keystore);
sslCtxFactory.setKeyStorePassword(password);
sslCtxFactory.setKeyManagerPassword(keyPassword);
sslCtxFactory
- .setKeyStoreType(conf.get(THRIFT_SSL_KEYSTORE_TYPE_KEY, THRIFT_SSL_KEYSTORE_TYPE_DEFAULT));
+ .setKeyStoreType(X509Util.resolveConfig(conf, THRIFT_SSL_SERVER_KEYSTORE_TYPE_KEY,
+ THRIFT_SSL_KEYSTORE_TYPE_KEY, THRIFT_SSL_KEYSTORE_TYPE_DEFAULT));
+
+ // Truststore is entirely new for Thrift — no legacy fallback because there is no historical
+ // hbase.thrift.ssl.truststore.* configuration. When left unset, no truststore is configured
+ // on the connector and any hbase.thrift.ssl.server.client.auth.mode = WANT/NEED setting
+ // will fail the handshake for lack of a peer-cert trust root.
Review Comment:
Opus 5.5 called out this: Jetty falls back to the JVM cacerts, so any publicly-CA-signed client cert is accepted and it will not cause a handshake fail. It should fail at startup if configs are missing or WARN about it to let the operator aware of the configuration issue.
##########
hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestInfoServerTLSConfig.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.http;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.testclassification.MiscTests;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Unit tests for {@link InfoServer}'s TLS-config resolution: the 3-tier fallback chain
+ * ({@code hbase.ui.ssl.server.*} → {@code hbase.ui.ssl.*} → {@code ssl.server.*}) that underpins
+ * single-EKU certificate support on the UI surface, and the client-auth-mode key.
+ */
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
+public class TestInfoServerTLSConfig {
+
+ private static final String POSTFIX = "keystore.location";
+ private static final String ROLE_SCOPED_KEY = "hbase.ui.ssl.server." + POSTFIX;
+ private static final String HBASE_KEY = "hbase.ui.ssl." + POSTFIX;
+ private static final String HADOOP_KEY = "ssl.server." + POSTFIX;
+
+ @Test
+ public void testRoleScopedTakesPrecedenceOverHBasePrefixed() {
+ Configuration c = new Configuration(false);
+ c.set(ROLE_SCOPED_KEY, "role-scoped-value");
+ c.set(HBASE_KEY, "hbase-prefixed-value");
+ c.set(HADOOP_KEY, "hadoop-prefixed-value");
+ assertEquals("role-scoped-value", InfoServer.getTLSProperty(c, POSTFIX));
+ }
+
+ @Test
+ public void testHBasePrefixedTakesPrecedenceOverHadoopPrefixed() {
+ Configuration c = new Configuration(false);
+ // No role-scoped key set — hbase-prefixed key must win.
+ c.set(HBASE_KEY, "hbase-prefixed-value");
+ c.set(HADOOP_KEY, "hadoop-prefixed-value");
+ assertEquals("hbase-prefixed-value", InfoServer.getTLSProperty(c, POSTFIX));
+ }
+
+ @Test
+ public void testFallsBackToHadoopPrefixedWhenNoOthersSet() {
+ Configuration c = new Configuration(false);
+ c.set(HADOOP_KEY, "hadoop-prefixed-value");
+ assertEquals("hadoop-prefixed-value", InfoServer.getTLSProperty(c, POSTFIX));
+ }
+
+ @Test
+ public void testReturnsDefaultWhenNoneSet() {
+ Configuration c = new Configuration(false);
+ assertEquals("jks", InfoServer.getTLSProperty(c, POSTFIX, "jks"));
+ assertNull(InfoServer.getTLSProperty(c, POSTFIX));
+ }
+
+ @Test
+ public void testGetTLSPasswordHonorsThreeTierFallback() throws Exception {
+ Configuration c = new Configuration(false);
+ // Configuration.getPassword returns null when unset; verifying the fallback picks each tier.
+ c.set(ROLE_SCOPED_KEY.replace("keystore.location", "keystore.password"), "role-pw");
+ c.set(HBASE_KEY.replace("keystore.location", "keystore.password"), "hbase-pw");
+ c.set(HADOOP_KEY.replace("keystore.location", "keystore.password"), "hadoop-pw");
+ assertEquals("role-pw", InfoServer.getTLSPassword(c, "keystore.password"));
+
+ c.unset(ROLE_SCOPED_KEY.replace("keystore.location", "keystore.password"));
+ assertEquals("hbase-pw", InfoServer.getTLSPassword(c, "keystore.password"));
+
+ c.unset(HBASE_KEY.replace("keystore.location", "keystore.password"));
+ assertEquals("hadoop-pw", InfoServer.getTLSPassword(c, "keystore.password"));
+
+ c.unset(HADOOP_KEY.replace("keystore.location", "keystore.password"));
+ assertNull(InfoServer.getTLSPassword(c, "keystore.password"));
+ }
+
+ @Test
+ public void testClientAuthModeKeyIsRoleScoped() {
+ // Guard against a "double server.server." regression: the client-auth-mode config key must
+ // resolve to the single role-scoped key, not to a nested/prefixed form.
+ assertEquals("hbase.ui.ssl.server.client.auth.mode", InfoServer.HBASE_UI_SSL_CLIENT_AUTH_MODE);
+ }
Review Comment:
What is the point of this test?
##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -175,20 +288,27 @@ public static SslContext createSslContextForClient(Configuration config)
SslContextBuilder sslContextBuilder = SslContextBuilder.forClient();
configureOpenSslIfAvailable(sslContextBuilder, config);
- String keyStoreLocation = config.get(TLS_CONFIG_KEYSTORE_LOCATION, "");
- char[] keyStorePassword = config.getPassword(TLS_CONFIG_KEYSTORE_PASSWORD);
- String keyStoreType = config.get(TLS_CONFIG_KEYSTORE_TYPE, "");
+ String keyStoreLocation =
+ resolveConfig(config, TLS_CONFIG_CLIENT_KEYSTORE_LOCATION, TLS_CONFIG_KEYSTORE_LOCATION, "");
+ char[] keyStorePassword =
+ resolvePassword(config, TLS_CONFIG_CLIENT_KEYSTORE_PASSWORD, TLS_CONFIG_KEYSTORE_PASSWORD);
+ String keyStoreType =
+ resolveConfig(config, TLS_CONFIG_CLIENT_KEYSTORE_TYPE, TLS_CONFIG_KEYSTORE_TYPE, "");
if (keyStoreLocation.isEmpty()) {
- LOG.warn(TLS_CONFIG_KEYSTORE_LOCATION + " not specified");
+ LOG.warn("Neither {} nor {} specified", TLS_CONFIG_CLIENT_KEYSTORE_LOCATION,
+ TLS_CONFIG_KEYSTORE_LOCATION);
} else {
sslContextBuilder
.keyManager(createKeyManager(keyStoreLocation, keyStorePassword, keyStoreType));
}
- String trustStoreLocation = config.get(TLS_CONFIG_TRUSTSTORE_LOCATION, "");
- char[] trustStorePassword = config.getPassword(TLS_CONFIG_TRUSTSTORE_PASSWORD);
- String trustStoreType = config.get(TLS_CONFIG_TRUSTSTORE_TYPE, "");
+ String trustStoreLocation = resolveConfig(config, TLS_CONFIG_CLIENT_TRUSTSTORE_LOCATION,
+ TLS_CONFIG_TRUSTSTORE_LOCATION, "");
+ char[] trustStorePassword = resolvePassword(config, TLS_CONFIG_CLIENT_TRUSTSTORE_PASSWORD,
+ TLS_CONFIG_TRUSTSTORE_PASSWORD);
+ String trustStoreType =
+ resolveConfig(config, TLS_CONFIG_CLIENT_TRUSTSTORE_TYPE, TLS_CONFIG_TRUSTSTORE_TYPE, "");
Review Comment:
The fallback happens per config key. Setting only `hbase.rpc.tls.client.keystore.location` means that legacy password and type will be matched with it causing an error. These should not be combined.
##########
hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java:
##########
@@ -413,16 +423,58 @@ protected void setupHTTPServer() throws IOException {
httpsConfig.addCustomizer(new SecureRequestCustomizer());
SslContextFactory.Server sslCtxFactory = new SslContextFactory.Server();
- String keystore = conf.get(THRIFT_SSL_KEYSTORE_STORE_KEY);
+ // Prefer the role-scoped hbase.thrift.ssl.server.* keys, falling back to the historical
+ // unscoped hbase.thrift.ssl.* keys for backward compatibility with existing deployments.
+ String keystore = X509Util.resolveConfig(conf, THRIFT_SSL_SERVER_KEYSTORE_STORE_KEY,
+ THRIFT_SSL_KEYSTORE_STORE_KEY, null);
String password =
- HBaseConfiguration.getPassword(conf, THRIFT_SSL_KEYSTORE_PASSWORD_KEY, null);
+ HBaseConfiguration.getPassword(conf, THRIFT_SSL_SERVER_KEYSTORE_PASSWORD_KEY,
+ HBaseConfiguration.getPassword(conf, THRIFT_SSL_KEYSTORE_PASSWORD_KEY, null));
String keyPassword =
- HBaseConfiguration.getPassword(conf, THRIFT_SSL_KEYSTORE_KEYPASSWORD_KEY, password);
+ HBaseConfiguration.getPassword(conf, THRIFT_SSL_SERVER_KEYSTORE_KEYPASSWORD_KEY,
+ HBaseConfiguration.getPassword(conf, THRIFT_SSL_KEYSTORE_KEYPASSWORD_KEY, password));
sslCtxFactory.setKeyStorePath(keystore);
sslCtxFactory.setKeyStorePassword(password);
sslCtxFactory.setKeyManagerPassword(keyPassword);
sslCtxFactory
- .setKeyStoreType(conf.get(THRIFT_SSL_KEYSTORE_TYPE_KEY, THRIFT_SSL_KEYSTORE_TYPE_DEFAULT));
+ .setKeyStoreType(X509Util.resolveConfig(conf, THRIFT_SSL_SERVER_KEYSTORE_TYPE_KEY,
+ THRIFT_SSL_KEYSTORE_TYPE_KEY, THRIFT_SSL_KEYSTORE_TYPE_DEFAULT));
+
+ // Truststore is entirely new for Thrift — no legacy fallback because there is no historical
+ // hbase.thrift.ssl.truststore.* configuration. When left unset, no truststore is configured
+ // on the connector and any hbase.thrift.ssl.server.client.auth.mode = WANT/NEED setting
+ // will fail the handshake for lack of a peer-cert trust root.
Review Comment:
Same problem is present in REST and InfoServer.
##########
hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/tls/TestX509Util.java:
##########
@@ -375,4 +376,142 @@ public void testLoadPKCS12TrustStoreWithWrongPassword() {
});
}
+ // ---------------------------------------------------------------------------
+ // Role-scoped configuration resolution (single-EKU certificate support)
+ // ---------------------------------------------------------------------------
+
+ @TestTemplate
+ public void testResolveConfigPrefersRoleScopedOverLegacy() {
+ conf.set("test.role", "role-value");
+ conf.set("test.legacy", "legacy-value");
+ assertEquals("role-value",
+ X509Util.resolveConfig(conf, "test.role", "test.legacy", "default-value"));
+ }
+
+ @TestTemplate
+ public void testResolveConfigFallsBackToLegacyWhenRoleUnset() {
+ conf.unset("test.role");
+ conf.set("test.legacy", "legacy-value");
+ assertEquals("legacy-value",
+ X509Util.resolveConfig(conf, "test.role", "test.legacy", "default-value"));
+ }
+
+ @TestTemplate
+ public void testResolveConfigReturnsDefaultWhenBothUnset() {
+ conf.unset("test.role");
+ conf.unset("test.legacy");
+ assertEquals("default-value",
+ X509Util.resolveConfig(conf, "test.role", "test.legacy", "default-value"));
+ }
+
+ @TestTemplate
+ public void testResolvePasswordPrefersRoleScopedOverLegacy() throws Exception {
+ conf.set("test.role.password", "role-pw");
+ conf.set("test.legacy.password", "legacy-pw");
+ assertArrayEquals("role-pw".toCharArray(),
+ X509Util.resolvePassword(conf, "test.role.password", "test.legacy.password"));
+ }
+
+ @TestTemplate
+ public void testResolvePasswordFallsBackToLegacyWhenRoleUnset() throws Exception {
+ conf.unset("test.role.password");
+ conf.set("test.legacy.password", "legacy-pw");
+ assertArrayEquals("legacy-pw".toCharArray(),
+ X509Util.resolvePassword(conf, "test.role.password", "test.legacy.password"));
+ }
+
+ @TestTemplate
+ public void testResolvePasswordReturnsNullWhenBothUnset() throws Exception {
+ conf.unset("test.role.password");
+ conf.unset("test.legacy.password");
+ assertNull(X509Util.resolvePassword(conf, "test.role.password", "test.legacy.password"));
+ }
+
+ @TestTemplate
+ public void testCreateSSLContextForClientUsesRoleScopedKeystoreWhenSet() throws Exception {
+ // Move the legacy keystore values to the client-scoped keys and clear the legacy keys, so
+ // that a successful context build proves the client-scoped keys were consulted.
+ String location = conf.get(X509Util.TLS_CONFIG_KEYSTORE_LOCATION);
+ String password = conf.get(X509Util.TLS_CONFIG_KEYSTORE_PASSWORD);
+ String type = conf.get(X509Util.TLS_CONFIG_KEYSTORE_TYPE);
+ conf.set(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_LOCATION, location);
+ conf.set(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_PASSWORD, password);
+ conf.set(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_TYPE, type);
+ conf.unset(X509Util.TLS_CONFIG_KEYSTORE_LOCATION);
+ conf.unset(X509Util.TLS_CONFIG_KEYSTORE_PASSWORD);
+ conf.unset(X509Util.TLS_CONFIG_KEYSTORE_TYPE);
+
+ SslContext sslContext = X509Util.createSslContextForClient(conf);
+ ByteBufAllocator byteBufAllocatorMock = mock(ByteBufAllocator.class);
+ // Handshake would fail if the key manager weren't wired; smoke-test that engine creation works.
+ assertTrue(
+ sslContext.newEngine(byteBufAllocatorMock).getSSLParameters().getProtocols().length > 0);
+ }
+
+ @TestTemplate
+ public void testCreateSSLContextForClientFallsBackToLegacyKeystore() throws Exception {
+ // The base setUp() only sets the legacy TLS_CONFIG_KEYSTORE_* / TLS_CONFIG_TRUSTSTORE_* keys.
+ // The role-scoped keys are intentionally unset; the context must still build using the legacy
+ // values (backward-compat regression guard).
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_LOCATION);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_PASSWORD);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_KEYSTORE_TYPE);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_TRUSTSTORE_LOCATION);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_TRUSTSTORE_PASSWORD);
+ conf.unset(X509Util.TLS_CONFIG_CLIENT_TRUSTSTORE_TYPE);
Review Comment:
Isn't this a no-op?
Apart from that this test is the same as `testCreateSSLContextWithoutCustomProtocol` but that also validates the TLS protocols, not just if it is not empty.
##########
hbase-http/src/main/java/org/apache/hadoop/hbase/http/InfoServer.java:
##########
@@ -83,6 +94,16 @@ public InfoServer(String name, String bindAddress, int port, boolean findPort,
.setExcludeProtocols(getTLSProperty(c, "exclude.protocols"))
.setIncludeCiphers(getTLSProperty(c, "include.cipher.list"))
.setExcludeCiphers(getTLSProperty(c, "exclude.cipher.list"));
+
+ // Activate mutual TLS if configured. Default is NONE, which preserves today's behavior of
+ // never requesting a client certificate on the UI connector (leaving any configured
+ // truststore inert for peer verification). Set hbase.ui.ssl.server.client.auth.mode to
+ // WANT or NEED to opt in. The client.auth.mode key is looked up directly on
+ // HBASE_WEB_TLS_SERVER_CONFIG_PREFIX; there is no legacy or Hadoop-prefixed fallback.
+ X509Util.ClientAuth clientAuth = X509Util.ClientAuth
+ .fromPropertyValue(c.get(HBASE_UI_SSL_CLIENT_AUTH_MODE, X509Util.ClientAuth.NONE.name()));
Review Comment:
It might be an edge case but when the config is in `hbase-site.xml` with empty value then it will use `NEED` not `NONE` when the config is not there at all.
```
/**
* Converts a property value to a ClientAuth enum. If the input string is empty or null, returns
* <code>ClientAuth.NEED</code>.
* @param prop the property string.
* @return the ClientAuth.
* @throws IllegalArgumentException if the property value is not "NONE", "WANT", "NEED", or
* empty/null.
*/
```
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "lucakovacs (via GitHub)" <gi...@apache.org>.
lucakovacs commented on code in PR #8681:
URL: https://github.com/apache/hbase/pull/8681#discussion_r4270529938
##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -422,20 +561,52 @@ private static String[] getCipherSuites(Configuration config) {
}
/**
- * Enable certificate file reloading by creating FileWatchers for keystore and truststore.
- * AtomicReferences will be set with the new instances. resetContext - if not null - will be
- * called when the file has been modified.
+ * Enable certificate file reloading for the RPC <em>client</em> side by creating FileWatchers for
+ * the keystore and truststore whose paths are resolved by {@link Role#CLIENT} (role-scoped keys
+ * first, legacy keys as fallback). AtomicReferences will be set with the new instances.
+ * {@code resetContext} - if not null - will be called when the file has been modified.
* @param keystoreWatcher Reference to keystoreFileWatcher.
* @param trustStoreWatcher Reference to truststoreFileWatcher.
* @param resetContext Callback for file changes.
*/
- public static void enableCertFileReloading(Configuration config,
+ public static void enableCertFileReloadingForClient(Configuration config,
AtomicReference<FileChangeWatcher> keystoreWatcher,
AtomicReference<FileChangeWatcher> trustStoreWatcher, Runnable resetContext)
throws IOException {
- String keyStoreLocation = config.get(TLS_CONFIG_KEYSTORE_LOCATION, "");
+ enableCertFileReloading(config, Role.CLIENT, keystoreWatcher, trustStoreWatcher, resetContext);
+ }
+
+ /**
+ * Enable certificate file reloading for the RPC <em>server</em> side. See
+ * {@link #enableCertFileReloadingForClient} for parameter semantics; the only difference is that
+ * paths are resolved via the {@link Role#SERVER} role-scoped keys, falling back to the legacy
+ * unscoped keys when unset.
+ */
+ public static void enableCertFileReloadingForServer(Configuration config,
+ AtomicReference<FileChangeWatcher> keystoreWatcher,
+ AtomicReference<FileChangeWatcher> trustStoreWatcher, Runnable resetContext)
+ throws IOException {
+ enableCertFileReloading(config, Role.SERVER, keystoreWatcher, trustStoreWatcher, resetContext);
+ }
+
+ private static void enableCertFileReloading(Configuration config, Role role,
+ AtomicReference<FileChangeWatcher> keystoreWatcher,
+ AtomicReference<FileChangeWatcher> trustStoreWatcher, Runnable resetContext)
+ throws IOException {
+ String keyStoreLocation;
+ String trustStoreLocation;
+ if (role == Role.CLIENT) {
+ keyStoreLocation = resolveConfig(config, TLS_CONFIG_CLIENT_KEYSTORE_LOCATION,
+ TLS_CONFIG_KEYSTORE_LOCATION, "");
+ trustStoreLocation = resolveConfig(config, TLS_CONFIG_CLIENT_TRUSTSTORE_LOCATION,
+ TLS_CONFIG_TRUSTSTORE_LOCATION, "");
+ } else {
+ keyStoreLocation = resolveConfig(config, TLS_CONFIG_SERVER_KEYSTORE_LOCATION,
+ TLS_CONFIG_KEYSTORE_LOCATION, "");
+ trustStoreLocation = resolveConfig(config, TLS_CONFIG_SERVER_TRUSTSTORE_LOCATION,
+ TLS_CONFIG_TRUSTSTORE_LOCATION, "");
Review Comment:
@PDavid in the latest commit [1f573d4](https://github.com/apache/hbase/pull/8681/changes/1f573d4c885056aad3163dd7f2768c9125eac4de) I fixed this issue by using the `TLSStore.resolve()` methods.
By doing so, the `resolveConfig()` and `resolvePassword()` functions became unused so I deleted them and all the related code with it
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "petersomogyi (via GitHub)" <gi...@apache.org>.
petersomogyi commented on code in PR #8681:
URL: https://github.com/apache/hbase/pull/8681#discussion_r4094252450
##########
hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestRESTServerSSL.java:
##########
@@ -160,6 +161,98 @@ public void testSslConnectionUsingKeystoreFormatPKCS12() throws Exception {
assertEquals(200, response.getCode());
}
+ // ---------------------------------------------------------------------------
+ // Role-scoped configuration + mTLS (single-EKU certificate support).
+ // ---------------------------------------------------------------------------
+
+ /**
+ * Server started with only the role-scoped hbase.rest.ssl.server.* keys (and legacy keys unset).
+ * A successful SSL connection proves the server-scoped keys were consulted.
+ */
+ @Test
+ public void testSslConnectionUsingRoleScopedServerKeys() throws Exception {
+ // Move the legacy passwords set in beforeEachTest onto the role-scoped keys and clear the
+ // legacy passwords so a successful start proves the server-scoped keys are what the code
+ // actually picked up.
+ conf.unset(Constants.REST_SSL_KEYSTORE_PASSWORD);
+ conf.unset(Constants.REST_SSL_KEYSTORE_KEYPASSWORD);
+ conf.unset(Constants.REST_SSL_TRUSTSTORE_PASSWORD);
+ conf.set(Constants.REST_SSL_SERVER_KEYSTORE_PASSWORD, KEY_STORE_PASSWORD);
+ conf.set(Constants.REST_SSL_SERVER_KEYSTORE_KEYPASSWORD, KEY_STORE_PASSWORD);
+ conf.set(Constants.REST_SSL_SERVER_TRUSTSTORE_PASSWORD, TRUST_STORE_PASSWORD);
+ conf.set(Constants.REST_SSL_SERVER_KEYSTORE_STORE, getKeystoreFilePath("jks"));
+ conf.set(Constants.REST_SSL_SERVER_TRUSTSTORE_STORE, getTruststoreFilePath("jks"));
+
+ REST_TEST_UTIL.startServletContainer(conf);
+ Cluster localCluster = new Cluster().add("localhost", REST_TEST_UTIL.getServletPort());
+ sslClient = new Client(localCluster, getTruststoreFilePath("jks"),
+ Optional.of(TRUST_STORE_PASSWORD), Optional.empty());
+
+ Response response = sslClient.get("/version", Constants.MIMETYPE_TEXT);
+ assertEquals(200, response.getCode());
+ }
+
+ /**
+ * Backward-compatibility regression: existing deployments that know only about the legacy
+ * unscoped keys must continue to work exactly as before. This mirrors {@link #testSslConnection}
+ * but names the intent explicitly.
+ */
+ @Test
+ public void testSslConnectionFallsBackToLegacyKeystoreKeys() throws Exception {
+ // Make sure no role-scoped key is set — the beforeEachTest configures only legacy passwords,
+ // so this is a fresh state check.
+ conf.unset(Constants.REST_SSL_SERVER_KEYSTORE_STORE);
+ conf.unset(Constants.REST_SSL_SERVER_KEYSTORE_PASSWORD);
+ conf.unset(Constants.REST_SSL_SERVER_KEYSTORE_KEYPASSWORD);
+ conf.unset(Constants.REST_SSL_SERVER_KEYSTORE_TYPE);
+ conf.unset(Constants.REST_SSL_SERVER_TRUSTSTORE_STORE);
+ conf.unset(Constants.REST_SSL_SERVER_TRUSTSTORE_PASSWORD);
+ conf.unset(Constants.REST_SSL_SERVER_TRUSTSTORE_TYPE);
+
+ startRESTServerWithDefaultKeystoreType();
+
+ Response response = sslClient.get("/version", Constants.MIMETYPE_TEXT);
+ assertEquals(200, response.getCode());
+ }
+
+ /**
+ * With {@code client.auth.mode=NONE} (the default), a client that presents no client certificate
+ * is accepted — matching today's behavior.
+ */
+ @Test
+ public void testClientAuthNoneAcceptsClientWithoutCert() throws Exception {
+ conf.set(Constants.REST_SSL_CLIENT_AUTH_MODE, "NONE");
+ startRESTServerWithDefaultKeystoreType();
+
+ Response response = sslClient.get("/version", Constants.MIMETYPE_TEXT);
+ assertEquals(200, response.getCode());
+ }
+
+ /**
+ * With {@code client.auth.mode=WANT}, an anonymous client (no client cert) is still accepted; the
+ * server requests a cert but does not require it.
+ */
+ @Test
+ public void testClientAuthWantAllowsAnonymousClient() throws Exception {
+ conf.set(Constants.REST_SSL_CLIENT_AUTH_MODE, "WANT");
+ startRESTServerWithDefaultKeystoreType();
+
+ Response response = sslClient.get("/version", Constants.MIMETYPE_TEXT);
+ assertEquals(200, response.getCode());
+ }
+
+ /**
+ * With {@code client.auth.mode=NEED}, an anonymous client (no client cert) is rejected by the
+ * server. The base {@link Client} configures truststore-only, so it presents no key material to
+ * the server.
+ */
+ @Test
+ public void testClientAuthNeedRejectsClientWithoutCert() throws Exception {
+ conf.set(Constants.REST_SSL_CLIENT_AUTH_MODE, "NEED");
+ startRESTServerWithDefaultKeystoreType();
+ assertThrows(SSLException.class, () -> sslClient.get("/version"));
Review Comment:
This should be changed to IOException like in TestThriftServerSSLMutualAuth.
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on code in PR #8681:
URL: https://github.com/apache/hbase/pull/8681#discussion_r4256590395
##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -422,20 +561,52 @@ private static String[] getCipherSuites(Configuration config) {
}
/**
- * Enable certificate file reloading by creating FileWatchers for keystore and truststore.
- * AtomicReferences will be set with the new instances. resetContext - if not null - will be
- * called when the file has been modified.
+ * Enable certificate file reloading for the RPC <em>client</em> side by creating FileWatchers for
+ * the keystore and truststore whose paths are resolved by {@link Role#CLIENT} (role-scoped keys
+ * first, legacy keys as fallback). AtomicReferences will be set with the new instances.
+ * {@code resetContext} - if not null - will be called when the file has been modified.
* @param keystoreWatcher Reference to keystoreFileWatcher.
* @param trustStoreWatcher Reference to truststoreFileWatcher.
* @param resetContext Callback for file changes.
*/
- public static void enableCertFileReloading(Configuration config,
+ public static void enableCertFileReloadingForClient(Configuration config,
AtomicReference<FileChangeWatcher> keystoreWatcher,
AtomicReference<FileChangeWatcher> trustStoreWatcher, Runnable resetContext)
throws IOException {
- String keyStoreLocation = config.get(TLS_CONFIG_KEYSTORE_LOCATION, "");
+ enableCertFileReloading(config, Role.CLIENT, keystoreWatcher, trustStoreWatcher, resetContext);
+ }
+
+ /**
+ * Enable certificate file reloading for the RPC <em>server</em> side. See
+ * {@link #enableCertFileReloadingForClient} for parameter semantics; the only difference is that
+ * paths are resolved via the {@link Role#SERVER} role-scoped keys, falling back to the legacy
+ * unscoped keys when unset.
+ */
+ public static void enableCertFileReloadingForServer(Configuration config,
+ AtomicReference<FileChangeWatcher> keystoreWatcher,
+ AtomicReference<FileChangeWatcher> trustStoreWatcher, Runnable resetContext)
+ throws IOException {
+ enableCertFileReloading(config, Role.SERVER, keystoreWatcher, trustStoreWatcher, resetContext);
+ }
+
+ private static void enableCertFileReloading(Configuration config, Role role,
+ AtomicReference<FileChangeWatcher> keystoreWatcher,
+ AtomicReference<FileChangeWatcher> trustStoreWatcher, Runnable resetContext)
+ throws IOException {
+ String keyStoreLocation;
+ String trustStoreLocation;
+ if (role == Role.CLIENT) {
+ keyStoreLocation = resolveConfig(config, TLS_CONFIG_CLIENT_KEYSTORE_LOCATION,
+ TLS_CONFIG_KEYSTORE_LOCATION, "");
+ trustStoreLocation = resolveConfig(config, TLS_CONFIG_CLIENT_TRUSTSTORE_LOCATION,
+ TLS_CONFIG_TRUSTSTORE_LOCATION, "");
+ } else {
+ keyStoreLocation = resolveConfig(config, TLS_CONFIG_SERVER_KEYSTORE_LOCATION,
+ TLS_CONFIG_KEYSTORE_LOCATION, "");
+ trustStoreLocation = resolveConfig(config, TLS_CONFIG_SERVER_TRUSTSTORE_LOCATION,
+ TLS_CONFIG_TRUSTSTORE_LOCATION, "");
Review Comment:
Rather minor question:
Can I ask what is the reason why we don't use `TLSStore.resolve()` here instead of `resolveConfig()` calls?
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on PR #8681:
URL: https://github.com/apache/hbase/pull/8681#issuecomment-5790802925
The newly added `org.apache.hadoop.hbase.rest.TestRESTServerSSL.testClientAuthNeedRejectsClientWithoutCert` test seems to fail. Can you please have a look?
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "petersomogyi (via GitHub)" <gi...@apache.org>.
petersomogyi commented on code in PR #8681:
URL: https://github.com/apache/hbase/pull/8681#discussion_r4164952627
##########
hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpServer.java:
##########
@@ -475,7 +491,18 @@ public HttpServer build() throws IOException {
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
SslContextFactory.Server sslCtxFactory = new SslContextFactory.Server();
+ // Requesting a client certificate without an explicit truststore would leave Jetty
+ // falling back to the keystore (or the JVM cacerts) as the client-cert trust anchor,
+ // silently trusting issuers the operator never configured. Fail fast instead.
+ X509Util.validateClientAuthTrustStore(
+ needsClientAuth
+ ? X509Util.ClientAuth.NEED
+ : (wantsClientAuth ? X509Util.ClientAuth.WANT : X509Util.ClientAuth.NONE),
+ trustStore, InfoServer.HBASE_UI_SSL_CLIENT_AUTH_MODE,
+ "hbase.ui.ssl.server.truststore.location", "hbase.ui.ssl.truststore.location",
+ "ssl.server.truststore.location");
Review Comment:
@lucakovacs this part wasn't touched in your last commit.
##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/TLSStore.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * 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.io.IOException;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * One keystore or truststore, resolved from configuration with every attribute drawn from a single
+ * key prefix.
+ * <p/>
+ * Each TLS surface exposes two prefixes for the same store: a role-scoped one added for single-EKU
+ * certificate support (e.g. {@code hbase.rpc.tls.server.}) and the historical unscoped one (e.g.
+ * {@code hbase.rpc.tls.}). Resolving attribute by attribute would let a store's location come from
+ * one prefix while its password or type came from the other, which opens either the wrong file or
+ * the right file with the wrong credentials. {@link #resolve} therefore picks the prefix once, from
+ * the location, and reads the rest of the store from that same prefix.
+ */
+@InterfaceAudience.Private
+public final class TLSStore {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TLSStore.class);
+
+ /**
+ * Tracks which prefixes have already been reported, so a JVM logs at most one line per store
+ * regardless of how many times a context is built.
+ */
+ private static final Set<String> LOGGED_STORES = ConcurrentHashMap.newKeySet();
+
+ /**
+ * The key postfixes making up one store, by surface. The RPC keys use {@code .location} while the
+ * servlet surfaces (REST, Thrift) use {@code .store}, and only the latter have a separate
+ * {@code keypassword}.
+ */
+ public enum Keys {
+ RPC_KEYSTORE("keystore.location", "keystore.password", "keystore.type", null),
+ RPC_TRUSTSTORE("truststore.location", "truststore.password", "truststore.type", null),
+ SERVLET_KEYSTORE("keystore.store", "keystore.password", "keystore.type",
+ "keystore.keypassword"),
+ SERVLET_TRUSTSTORE("truststore.store", "truststore.password", "truststore.type", null);
+
+ private final String location;
+ private final String password;
+ private final String type;
+ private final String keyPassword;
+
+ Keys(String location, String password, String type, String keyPassword) {
+ this.location = location;
+ this.password = password;
+ this.type = type;
+ this.keyPassword = keyPassword;
+ }
+
+ private String[] all() {
+ return keyPassword == null
+ ? new String[] { location, password, type }
+ : new String[] { location, password, type, keyPassword };
+ }
+ }
+
+ private final String location;
+ private final char[] password;
+ private final char[] keyPassword;
+ private final String type;
+
+ private TLSStore(String location, char[] password, char[] keyPassword, String type) {
+ this.location = location;
+ this.password = password;
+ this.keyPassword = keyPassword;
+ this.type = type;
+ }
+
+ /**
+ * Reads one store from {@code config}. The prefix supplying the location supplies every other
+ * attribute too, so the two prefixes are never combined within a single store.
+ * <p/>
+ * Only the location is mandatory under a prefix: a store may have no password at all, and the
+ * type is auto-detected from the file extension when absent (see
+ * {@link KeyStoreFileType#fromPropertyValueOrFileName}). Keeping the legacy keys in place while
+ * migrating is valid -- the ones left unused are logged once so they can be cleaned up.
+ * @param config the configuration to read from
+ * @param rolePrefix role-scoped prefix, e.g. {@code hbase.rpc.tls.server.}
+ * @param legacyPrefix historical unscoped prefix, e.g. {@code hbase.rpc.tls.}
+ * @param keys which store to read, and under which postfixes
+ * @throws IllegalArgumentException if {@code rolePrefix} supplies any attribute but not the
+ * location, since the location would then be taken from
+ * {@code legacyPrefix}
+ */
+ public static TLSStore resolve(Configuration config, String rolePrefix, String legacyPrefix,
+ Keys keys) throws IOException {
+ String roleLocationKey = rolePrefix + keys.location;
+ boolean useRole = config.get(roleLocationKey) != null;
+ if (!useRole) {
+ for (String postfix : keys.all()) {
+ if (config.get(rolePrefix + postfix) != null) {
+ throw new IllegalArgumentException(
+ rolePrefix + postfix + " is set, but " + roleLocationKey + " is not. Once any "
+ + rolePrefix + " key is used, that prefix must supply the store location.");
+ }
+ }
+ }
+ String prefix = useRole ? rolePrefix : legacyPrefix;
+ if (useRole) {
+ logOnce(config, rolePrefix, legacyPrefix, keys);
+ }
+ return new TLSStore(config.get(prefix + keys.location, ""),
+ config.getPassword(prefix + keys.password),
+ keys.keyPassword == null ? null : config.getPassword(prefix + keys.keyPassword),
+ config.get(prefix + keys.type, ""));
+ }
+
+ private static void logOnce(Configuration config, String rolePrefix, String legacyPrefix,
+ Keys keys) {
+ StringBuilder unused = new StringBuilder();
+ for (String postfix : keys.all()) {
+ if (config.get(legacyPrefix + postfix) != null) {
+ unused.append(unused.length() == 0 ? "" : ", ").append(legacyPrefix).append(postfix);
+ }
+ }
+ if (unused.length() > 0 && LOGGED_STORES.add(rolePrefix + keys.location)) {
+ LOG.warn("{} supplies this store, so these keys are unused: {}. Remove them once the"
+ + " migration is complete.", rolePrefix, unused);
+ }
+ }
Review Comment:
This part looks ugly. String.join is exactly for this behavior. Also, the LOGGED_STORES could be evaluate prior so the for loop/stream is not executed when it was already logged.
```
if (!LOGGED_STORES.add(rolePrefix + keys.location)) {
return;
}
List<String> unused = Arrays.stream(keys.all())
.map(postfix -> legacyPrefix + postfix)
.filter(key -> config.get(key) != null)
.collect(Collectors.toList());
if (!unused.isEmpty()) {
LOG.warn("{} supplies this store, so these keys are unused: {}. Remove them once the"
+ " migration is complete.", rolePrefix, String.join(", ", unused));
}
```
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on PR #8681:
URL: https://github.com/apache/hbase/pull/8681#issuecomment-6287957566
Hi @lucakovacs,
I merged the changes to master, many thanks for the contribution! :+1:
The patch does not apply cleanly against `branch-2`. Can you please create a PR for `branch-2`?
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on code in PR #8681:
URL: https://github.com/apache/hbase/pull/8681#discussion_r4133130719
##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -278,6 +279,44 @@ public static char[] resolvePassword(Configuration config, String roleKey, Strin
return value;
}
+ // resolveConfig falls back per key, so a store whose location comes from one prefix and whose
+ // password/type come from the other would open the wrong file, or the right file with the wrong
+ // credentials. A store is a unit: reject configs that straddle both prefixes.
+ public static void validateConfigPrefixConsistency(Configuration config, String rolePrefix,
Review Comment:
Many thanks for adding this method which checks the consistency. 👍 Would it maybe make sense to add unit test for this?
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "lucakovacs (via GitHub)" <gi...@apache.org>.
lucakovacs commented on PR #8681:
URL: https://github.com/apache/hbase/pull/8681#issuecomment-5869395583
I made the following changes according to @petersomogyi's review:
- Changed the SSLException to IOException in the TestRESTServerSSL.java file
- Deleted the two tests in TestX509Util.java since after the no-op code was removed the remaining parts are covered in other tests.
- Deleted testClientAuthModeKeyIsRoleScoped() in TestInfoServerTLSConfig.java since it’s not testing any functional behaviour
- Added a helper method validateClientAuthTrustStore to avoid Jetty’s fallback mechanism in Thrift/InfoServer/REST when no truststore is set. Also added tests to test the validation
- Added inline expressions for Thrift/REST/Infoserver when resolving client auth mode to avoid whitespace resolved as NEED
- Added a config validator method for checking mixed role configuration
If acceptable, I would to the documentation on an other PR or JIRA if needed
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "petersomogyi (via GitHub)" <gi...@apache.org>.
petersomogyi commented on code in PR #8681:
URL: https://github.com/apache/hbase/pull/8681#discussion_r4143237397
##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/tls/X509Util.java:
##########
@@ -278,6 +279,44 @@ public static char[] resolvePassword(Configuration config, String roleKey, Strin
return value;
}
+ // resolveConfig falls back per key, so a store whose location comes from one prefix and whose
+ // password/type come from the other would open the wrong file, or the right file with the wrong
+ // credentials. A store is a unit: reject configs that straddle both prefixes.
+ public static void validateConfigPrefixConsistency(Configuration config, String rolePrefix,
Review Comment:
While this validation is ok I think it can be problematic when an operator is migrating to the new configs.
It is not possible to add the new configs (all of the single EKU related) while the dual-use configs are still in place.
Wouldn't it make sense to fetch all the single EKU configs and if that misses any of the required key-value pairs then throw an exception?
IMO having all single use and all dual use configs is still a valid setup, maybe a WARN log can be added to "remove the legacy once migration is completed"
##########
hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpServer.java:
##########
@@ -475,7 +491,18 @@ public HttpServer build() throws IOException {
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
SslContextFactory.Server sslCtxFactory = new SslContextFactory.Server();
+ // Requesting a client certificate without an explicit truststore would leave Jetty
+ // falling back to the keystore (or the JVM cacerts) as the client-cert trust anchor,
+ // silently trusting issuers the operator never configured. Fail fast instead.
+ X509Util.validateClientAuthTrustStore(
+ needsClientAuth
+ ? X509Util.ClientAuth.NEED
+ : (wantsClientAuth ? X509Util.ClientAuth.WANT : X509Util.ClientAuth.NONE),
+ trustStore, InfoServer.HBASE_UI_SSL_CLIENT_AUTH_MODE,
+ "hbase.ui.ssl.server.truststore.location", "hbase.ui.ssl.truststore.location",
+ "ssl.server.truststore.location");
Review Comment:
* the last three parameters are only used in the exception message, the actual check is just "clientAuth != NONE && blank(trustStore) → throw"
* The HttpServer is a generic base class, but those `hbase.ui.ssl.*` key names belong to `InfoServer`. Could this validation live in InfoServer instead, right after `clientAuth` is computed? That's also where the resolved truststore location and the correct key names are already in hand and it matches how REST/Thrift call `validateClientAuthTrustStore` from their own setup.
* That move also removes the nested ternary here (InfoServer already has the ClientAuth enum, so it need not reconstruct it from the two booleans). It's hard to see which arguments are actually passed using this nested ternary operators.
--
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
Re: [PR] HBASE-30387: Support SingleEKU certificates [hbase]
Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid merged PR #8681:
URL: https://github.com/apache/hbase/pull/8681
--
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