codope commented on code in PR #7576:
URL: https://github.com/apache/hudi/pull/7576#discussion_r1083674703
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/schema/SchemaRegistryProvider.java:
##########
@@ -94,6 +121,33 @@ protected InputStream getStream(HttpURLConnection
connection) throws IOException
public SchemaRegistryProvider(TypedProperties props, JavaSparkContext jssc) {
super(props, jssc);
DataSourceUtils.checkRequiredProperties(props,
Collections.singletonList(Config.SRC_SCHEMA_REGISTRY_URL_PROP));
+ if (config.containsKey(Config.SSL_KEYSTORE_LOCATION_PROP)
+ || config.containsKey(Config.SSL_TRUSTSTORE_LOCATION_PROP)) {
+ setUpSSLStores();
+ }
+ }
+
+ private void setUpSSLStores() {
+ SSLContextBuilder sslContextBuilder = SSLContexts.custom();
+ try {
+ if (config.containsKey(Config.SSL_TRUSTSTORE_LOCATION_PROP)) {
+ sslContextBuilder.loadTrustMaterial(
+ new File(config.getString(Config.SSL_TRUSTSTORE_LOCATION_PROP)),
+
config.getString(Config.SSL_TRUSTSTORE_PASSWORD_PROP).toCharArray(),
+ new TrustSelfSignedStrategy());
+ }
+ if (config.containsKey(Config.SSL_KEYSTORE_LOCATION_PROP)) {
+ sslContextBuilder.loadKeyMaterial(
+ new File(config.getString(Config.SSL_KEYSTORE_LOCATION_PROP)),
+ config.getString(Config.SSL_KEYSTORE_PASSWORD_PROP).toCharArray(),
+ config.getString(Config.SSL_KEY_PASSWORD_PROP).toCharArray()
+ );
+ }
+ sslSocketFactory = sslContextBuilder.build().getSocketFactory();
+ } catch (UnrecoverableKeyException | IOException | KeyStoreException |
NoSuchAlgorithmException | CertificateException | KeyManagementException e) {
+ throw new RuntimeException(e);
Review Comment:
Should we wrap in `HoodieIOException` instead of `RuntimeException`, after
all it's file i/o?
##########
hudi-utilities/src/test/java/org/apache/hudi/utilities/schema/TestSchemaRegistryProvider.java:
##########
@@ -75,7 +76,7 @@ public void testGetSourceSchemaShouldRequestSchemaWithCreds()
throws IOException
assertNotNull(actual);
assertEquals(actual, getExpectedSchema(json));
verify(spyUnderTest, times(1)).setAuthorizationHeader(eq(basicAuth),
- Mockito.any(HttpURLConnection.class));
+ Mockito.any(HttpsURLConnection.class));
Review Comment:
This doesn't really test the `setUpSSLStores`. Does 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]