Package org.apache.hadoop.hbase.thrift
Class TestThriftServerSSLMutualAuth
java.lang.Object
org.apache.hadoop.hbase.thrift.TestThriftServerSSLMutualAuth
@Tag("org.apache.hadoop.hbase.testclassification.ClientTests") @Tag("org.apache.hadoop.hbase.testclassification.LargeTests")
public class TestThriftServerSSLMutualAuth
extends Object
Exercises the role-scoped
hbase.thrift.ssl.server.* configuration and the new mutual-TLS
activation on the Thrift-over-HTTP transport. Complements TestThriftHttpServerSSL, which
covers plain (server-only) TLS termination.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate org.apache.http.client.methods.HttpPostprivate static final Stringprivate Fileprivate static final org.slf4j.Loggerprivate static final HBaseTestingUtilprivate static final Stringprivate ThriftServerRunner -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate org.apache.hadoop.conf.ConfigurationbaseConf()private org.apache.hadoop.conf.Configurationprivate org.apache.http.impl.client.HttpClientBuilderBuilds a client that (a) trusts the server's cert and (b) presents the client keystore.private org.apache.http.impl.client.HttpClientBuilderprivate org.apache.http.client.methods.CloseableHttpResponsedoOneRoundTrip(org.apache.http.impl.client.CloseableHttpClient httpClient) private voiddoRequest(org.apache.http.impl.client.HttpClientBuilder builder) private voiddoRequestExpectingSuccess(org.apache.http.impl.client.HttpClientBuilder builder) private static voidgenerateKeyStore(String keyStorePath, KeyPair keyPair, X509Certificate cert) private static voidgenerateKeyStoreWithPassword(String keyStorePath, KeyPair keyPair, X509Certificate cert, String password) private static voidgenerateTrustStore(String path, X509Certificate cert) private Stringprivate Stringprivate Stringprivate Stringprivate static voidprivate Fileprivate static KeyStoreloadJksTrustStore(String path, String password) voidsetUp()static voidprivate voidstartServer(org.apache.hadoop.conf.Configuration conf) voidtearDown()static voidvoidNEEDaccepts a client that presents a certificate trusted by the server.voidNEEDrejects clients that do not present a valid client certificate.voidWithclient.auth.mode=NONE(default), a client presenting no certificate is accepted — matches today's behavior.voidWANTlets anonymous clients through.voidBackward-compatibility regression: existing deployments that know only about the legacy unscoped keys must continue to work.voidWith only the role-scopedhbase.thrift.ssl.server.keystore.*keys set (legacy keys unset), a plain HTTPS request succeeds — proving the server-scoped keys are the ones the bootstrap actually reads.
-
Field Details
-
LOG
-
TEST_UTIL
-
KEY_STORE_PASSWORD
- See Also:
-
TRUST_STORE_PASSWORD
- See Also:
-
CLIENT_KEY_STORE_PASSWORD
- See Also:
-
keyDir
-
tsr
-
httpPost
-
-
Constructor Details
-
TestThriftServerSSLMutualAuth
public TestThriftServerSSLMutualAuth()
-
-
Method Details
-
setUpBeforeClass
- Throws:
Exception
-
tearDownAfterClass
- Throws:
Exception
-
setUp
- Throws:
Exception
-
tearDown
- Throws:
IOException
-
testServerUsesRoleScopedKeystoreWhenSet
With only the role-scopedhbase.thrift.ssl.server.keystore.*keys set (legacy keys unset), a plain HTTPS request succeeds — proving the server-scoped keys are the ones the bootstrap actually reads.- Throws:
Exception
-
testServerFallsBackToLegacyKeystore
Backward-compatibility regression: existing deployments that know only about the legacy unscoped keys must continue to work.- Throws:
Exception
-
testClientAuthNoneAcceptsClientWithoutCert
Withclient.auth.mode=NONE(default), a client presenting no certificate is accepted — matches today's behavior.- Throws:
Exception
-
testClientAuthWantAllowsAnonymousClient
WANTlets anonymous clients through.- Throws:
Exception
-
testClientAuthNeedRejectsClientWithoutCert
NEEDrejects clients that do not present a valid client certificate. The handshake fails before any HTTP response is produced.- Throws:
Exception
-
testClientAuthNeedAcceptsClientWithValidCert
NEEDaccepts a client that presents a certificate trusted by the server.- Throws:
Exception
-
baseConf
- Throws:
Exception
-
baseConfWithLegacyKeystore
- Throws:
Exception
-
startServer
- Throws:
Exception
-
clientBuilderWithServerTrust
private org.apache.http.impl.client.HttpClientBuilder clientBuilderWithServerTrust() throws Exception- Throws:
Exception
-
clientBuilderWithMutualTrust
private org.apache.http.impl.client.HttpClientBuilder clientBuilderWithMutualTrust() throws ExceptionBuilds a client that (a) trusts the server's cert and (b) presents the client keystore. Used to satisfyclient.auth.mode=NEED.- Throws:
Exception
-
doRequestExpectingSuccess
private void doRequestExpectingSuccess(org.apache.http.impl.client.HttpClientBuilder builder) throws Exception - Throws:
Exception
-
doRequest
- Throws:
Exception
-
doOneRoundTrip
private org.apache.http.client.methods.CloseableHttpResponse doOneRoundTrip(org.apache.http.impl.client.CloseableHttpClient httpClient) throws Exception - Throws:
Exception
-
loadJksTrustStore
- Throws:
Exception
-
initializeAlgorithmId
-
initKeystoreDir
-
generateKeyStore
private static void generateKeyStore(String keyStorePath, KeyPair keyPair, X509Certificate cert) throws Exception - Throws:
Exception
-
generateKeyStoreWithPassword
private static void generateKeyStoreWithPassword(String keyStorePath, KeyPair keyPair, X509Certificate cert, String password) throws Exception - Throws:
Exception
-
generateTrustStore
- Throws:
Exception
-
getServerKeystoreFilePath
-
getServerTruststoreFilePath
-
getClientKeystoreFilePath
-
getClientCaTruststoreFilePath
-