nsivarajan commented on code in PR #64697:
URL: https://github.com/apache/doris/pull/64697#discussion_r3540953949


##########
fe/fe-core/src/main/java/org/apache/doris/common/util/InternalHttpsUtils.java:
##########
@@ -0,0 +1,83 @@
+// 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.doris.common.util;
+
+import org.apache.doris.common.Config;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.KeyStore;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
+/**
+ * Utility for creating SSL-aware HTTP clients for internal FE communication.
+ *
+ * <p>Builds an {@link SSLContext} from the configured CA truststore once and 
caches it.
+ * Hostname verification is disabled for IP-based intra-cluster connections.
+ * Certificate rotation requires a FE restart.
+ */
+public class InternalHttpsUtils {
+    private static volatile SSLContext cachedSslContext = null;
+
+    private static final Logger LOG = 
LogManager.getLogger(InternalHttpsUtils.class);
+
+    /**
+     * Returns the cached SSLContext, building it from the configured 
truststore on first call.
+     */
+    public static SSLContext getSslContext() {
+        if (cachedSslContext == null) {
+            synchronized (InternalHttpsUtils.class) {
+                if (cachedSslContext == null) {
+                    cachedSslContext = buildSslContext();
+                }
+            }
+        }
+        return cachedSslContext;
+    }
+
+    private static SSLContext buildSslContext() {
+        try {
+            // The same CA signs all Doris TLS certs (FE HTTPS + MySQL SSL), 
so mysql_ssl_default_ca_certificate
+            // is the correct trust anchor for FE HTTPS. Hostname verification 
is skipped for IP-based comms.
+            KeyStore trustStore = 
KeyStore.getInstance(Config.ssl_trust_store_type);

Review Comment:
   Fixed per your first suggested option — switched the trust anchor to the 
FE's own HTTPS keystore 
(Config.key_store_path/key_store_type/key_store_password), which is the actual 
config surface that serves FE
    HTTPS, instead of mysql_ssl_default_ca_certificate (a separate, 
independently-configured trust store scoped to MySQL wire-protocol SSL with no 
guaranteed relationship to the FE HTTPS cert).
     
    This is correct for the audit loader (always calls 127.0.0.1, i.e. itself) 
and also for genuine FE-to-FE calls as long as every FE node in the cluster 
shares the same keystore file — the expected internal-HTTPS
   deployment model. A cluster issuing a distinct cert per FE node would need a 
real CA-based trust store instead of this pinned-leaf approach; that's a larger 
change out of scope here.
    
    Also caught and fixed two related issues while rebasing onto the now-merged 
#60921: HttpUtils.executeRequest() was selecting the HTTPS client based on the 
global enable_https flag rather than the actual request's URI scheme (would 
unnecessarily — and in some misconfigurations, incorrectly — build the HTTPS 
client for plain http:// BE calls), and a duplicate getHttpPort() definition in 
HttpURLUtil.java that was
    a compile blocker.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to