lasdf1234 commented on code in PR #14934:
URL: https://github.com/apache/gravitino/pull/14934#discussion_r4546735136
##########
clients/client-java/src/main/java/org/apache/gravitino/client/TLSConfigurers.java:
##########
@@ -53,8 +93,52 @@ public static final class Builder {
private String keyStorePassword;
private String storeType = DEFAULT_STORE_TYPE;
+ private String[] protocols = new String[0];
+ private String[] cipherSuites = new String[0];
+
private Builder() {}
+ /**
+ * Configures the allowed TLS protocols.
+ *
+ * <p>If no protocols are specified, the default TLS protocols are used.
+ *
+ * @param protocols allowed TLS protocols, such as {@code TLSv1.3}
+ * @return this builder
+ */
+ public Builder protocols(String... protocols) {
Review Comment:
**Follow-up (round 3):** Addressed in `96609f6` — `validateTlsSettings()`
now checks against `sslContext.getSupportedSSLParameters()`, with unit tests
for unsupported protocol/cipher at `build()`.
##########
clients/client-java/src/main/java/org/apache/gravitino/client/TLSConfigurers.java:
##########
@@ -63,6 +147,9 @@ private Builder() {}
* @return this builder
*/
public Builder trustStore(Path path, String password) {
+ Preconditions.checkArgument(path != null, "Truststore path must not be
null");
+ Preconditions.checkArgument(password != null, "Truststore password must
not be null");
Review Comment:
**Follow-up (round 3):** Addressed — Javadoc on `trustStore` / `keyStore`
now notes that an empty password is permitted when the store format allows it.
##########
docs/how-to-use-gravitino-client.md:
##########
@@ -46,6 +46,97 @@ GravitinoAdminClient gravitinoAdminClient =
GravitinoAdminClient.builder("http:/
**Note:** Invalid configuration properties will result in exceptions.
+### Java Client TLS Configuration
+
+The Gravitino Java client supports custom TLS configuration through
`TLSConfigurers`. This includes custom truststores, mutual TLS (mTLS)
authentication, and restrictions on TLS protocols and cipher suites.
+
+For HTTPS connections using the default JVM truststore without client
certificate authentication, no additional TLS configuration is required.
+
+#### Custom Truststore
+
+To connect to a server using a private certificate authority (CA) or a
self-signed certificate, use `withTrustStore()`:
Review Comment:
**Follow-up (round 3):** Mostly addressed — the replace-not-merge note is
present. One small follow-up: the note currently names only `withTrustStore()`;
`withMutualTls()` and `builder().trustStore(...)` have the same replacement
semantics — please broaden the wording to “any custom truststore” (or list
those entry points).
##########
clients/client-java/src/main/java/org/apache/gravitino/client/TLSConfigurers.java:
##########
@@ -45,6 +45,46 @@ public static Builder builder() {
return new Builder();
}
+ /**
+ * Creates a TLS configurer using a custom truststore.
+ *
+ * @param path path to the truststore
+ * @param password truststore password
+ * @return the configured TLS configurer
+ */
+ public static TLSConfigurer withTrustStore(Path path, String password) {
+ return builder().trustStore(path, password).build();
+ }
+
+ /**
+ * Creates a TLS configurer using a default JVM truststore and a custom
client keystore.
+ *
+ * @param path path to the client keystore
+ * @param password keystore password
+ * @return the configured TLS configurer
+ */
+ public static TLSConfigurer withKeyStore(Path path, String password) {
Review Comment:
**Follow-up (round 3):** Acceptable resolution — `withKeyStore` Javadoc +
the test class comment/TODO document that a success IT needs a JVM-trusted
server cert fixture. No blocker if tracked as follow-up.
##########
clients/client-java/src/test/java/org/apache/gravitino/client/TestHTTPClientTLS.java:
##########
@@ -143,12 +140,32 @@ public void testClientRejectsUntrustedServerCertificate()
throws Exception {
jettyServer, false, createTestServlet(), TEST_SERVLET_PATH);
TLSConfigurer tlsConfigurer =
- TLSConfigurers.builder()
- .trustStore(
-
TestTlsServerUtils.testResource("test-untrusted-server-truststore.p12"),
- TEST_STORE_PASSWORD)
- .build();
+ TLSConfigurers.withTrustStore(
+
TestTlsServerUtils.testResource("test-untrusted-server-truststore.p12"),
+ TEST_STORE_PASSWORD);
+
+ try (HTTPClient client = createHttpsClient(port, tlsConfigurer)) {
+ RESTException exception =
+ assertThrows(
+ RESTException.class,
+ () -> client.head(TEST_CLIENT_PATH, ImmutableMap.of(), response
-> {}));
+
+ TestTlsServerUtils.assertHandshakeFailure(exception);
+ }
+ }
+
+ @Test
+ public void testMutualTLSWithDefaultTrustStoreRejectsUntrustedServer()
throws Exception {
Review Comment:
**Follow-up (round 3):** Same as above — fixture limitation is documented in
the test; OK to leave the success IT as TODO.
##########
clients/client-java/src/main/java/org/apache/gravitino/client/TLSConfigurers.java:
##########
@@ -45,6 +45,46 @@ public static Builder builder() {
return new Builder();
}
+ /**
+ * Creates a TLS configurer using a custom truststore.
+ *
+ * @param path path to the truststore
+ * @param password truststore password
+ * @return the configured TLS configurer
+ */
+ public static TLSConfigurer withTrustStore(Path path, String password) {
+ return builder().trustStore(path, password).build();
+ }
+
+ /**
+ * Creates a TLS configurer using a default JVM truststore and a custom
client keystore.
+ *
+ * @param path path to the client keystore
+ * @param password keystore password
+ * @return the configured TLS configurer
+ */
+ public static TLSConfigurer withKeyStore(Path path, String password) {
Review Comment:
**Follow-up (round 3):** Docs now cover helpers + replace semantics (see
also the note under Custom Truststore). Remaining nit: broaden the note beyond
`withTrustStore()` as commented on the docs thread.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]