You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "jnturton (via GitHub)" <gi...@apache.org> on 2023/04/25 14:39:49 UTC

[GitHub] [calcite] jnturton commented on a diff in pull request #3174: CALCITE-5671: Add Option to Disable SSL Certificate Validation to ES Adapter

jnturton commented on code in PR #3174:
URL: https://github.com/apache/calcite/pull/3174#discussion_r1176608199


##########
elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchSchemaFactory.java:
##########
@@ -93,6 +98,27 @@ public class ElasticsearchSchemaFactory implements SchemaFactory {
   public ElasticsearchSchemaFactory() {
   }
 
+  /**
+   * Create an ElasticSearch {@link Schema}.

Review Comment:
   Thank you for this documentation.



##########
elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/UnsafeX509ExtendedTrustManager.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.calcite.adapter.elasticsearch;
+
+import java.net.Socket;
+import java.security.cert.X509Certificate;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.X509ExtendedTrustManager;
+
+/**
+ * This class is used to disable SSL Certificate Verification in ElasticSearch.  This trust
+ * manager will validate any SSL certificate, whether valid or not. This should <b>not</b> be
+ * used in production environments.
+ */
+@SuppressWarnings("java:S4830")
+public final class UnsafeX509ExtendedTrustManager extends X509ExtendedTrustManager {

Review Comment:
   I don't know the Calcite code layout well but this trust manager is a generic utility that could easily be useful to other adapters so I'd personally look for a utils package to put it into.



##########
elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchSchemaFactory.java:
##########
@@ -151,18 +188,20 @@ public ElasticsearchSchemaFactory() {
    * @param password the password of ES
    * @return new or cached low-level rest http client for ES
    */
+  @SuppressWarnings({"java:S4830", "java:S5527"})
   private static RestClient connect(List<HttpHost> hosts, String pathPrefix,
-                                    String username, String password) {
+                                    String username, String password,
+                                    boolean disableSSLVerification) {
 
     Objects.requireNonNull(hosts, "hosts or coordinates");
     Preconditions.checkArgument(!hosts.isEmpty(), "no ES hosts specified");
     // Two lists are considered equal when all of their corresponding elements are equal
-    // making a list of RestClient parms a suitable cache key.
+    // making a list of RestClient params a suitable cache key.

Review Comment:
   I'm not suggesting any reversion here but "parm" is also a common abbreviation of parameter :)



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org