lasdf1234 commented on code in PR #14934:
URL: https://github.com/apache/gravitino/pull/14934#discussion_r4546364778
##########
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 2):** Thanks for the docs commit (`4db8e374`).
`docs/how-to-use-gravitino-client.md` now covers `withTrustStore` /
`withMutualTls` / `withKeyStore` and `protocols` / `cipherSuites` examples, and
`how-to-use-https.md` correctly moves local trust to a dedicated client
truststore.
One remaining docs gap: please state explicitly that a **custom truststore
replaces (does not merge with) the JVM default trust anchors for this client**.
Operators otherwise often ship a private-CA-only truststore and then break
other HTTPS from the same client (S3, IdP, etc.).
##########
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 2):** Docs now describe the `withKeyStore` CUJ (client
cert + default JVM trust). The **success-path IT** gap remains: still only a
rejection test against the private-CA Jetty fixture. Either add a success IT
when feasible, or document in Javadoc/user docs that success requires a server
chain already trusted by the JVM (current fixtures cannot demonstrate it).
##########
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 2):** Still open from the test side — same as the
`withKeyStore` success-path note above. No code change needed if you document
the fixture limitation.
--
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]