github-actions[bot] commented on code in PR #60921: URL: https://github.com/apache/doris/pull/60921#discussion_r3421495765
########## fe/fe-core/src/main/java/org/apache/doris/common/util/InternalHttpsUtils.java: ########## @@ -0,0 +1,98 @@ +// 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.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +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-to-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 { + KeyStore trustStore = KeyStore.getInstance(Config.ssl_trust_store_type); + try (InputStream stream = Files.newInputStream( + Paths.get(Config.mysql_ssl_default_ca_certificate))) { + trustStore.load(stream, Config.mysql_ssl_default_ca_certificate_password.toCharArray()); Review Comment: This truststore is independent from the certificate that the FE HTTPS server actually presents. `HttpServer` is configured from `Config.key_store_path`, `Config.key_store_type`, and `Config.key_store_password`, while this client trusts `Config.mysql_ssl_default_ca_certificate` with `Config.ssl_trust_store_type`. An existing HTTPS deployment can therefore have a valid FE `key_store_path` certificate that is not signed by the MySQL SSL CA, causing the new internal HTTPS calls (`/check`, `/role`, checkpoint image sync, query/profile fan-out) to fail PKIX validation. Please add/use a FE HTTPS truststore config that matches the server certificate chain, or derive this context from the configured FE HTTPS certificate/CA, and cover it with an end-to-end HTTPS client/server test. ########## fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java: ########## @@ -1823,7 +1822,7 @@ private void transferToMaster() { toMasterProgress = "log master info"; this.masterInfo = new MasterInfo(Env.getCurrentEnv().getSelfNode().getHost(), - Config.http_port, + HttpURLUtil.getHttpPort(), Config.rpc_port); Review Comment: Changing `MasterInfo` to store `https_port` makes every `Env.getMasterHttpPort()` consumer point at the HTTPS listener. One important consumer is `RestBaseController.forwardToMaster()` (used by APIs such as `/api/{db}/_cancel` and several `/rest/v2/...` manager calls): it builds the master URL from `request.getScheme()` plus `env.getMasterHttpPort()` and sends it with a vanilla `new RestTemplate()`. With `enable_https=true`, after the HTTP-to-HTTPS redirect that becomes `https://master:<https_port>/...`, but that `RestTemplate` does not use `InternalHttpsUtils`' truststore or hostname-verifier handling, so deployments using Doris/internal self-signed FE certificates fail with `SSLHandshakeException` instead of forwarding to the master. Please update the generic forward-to-master path to use the same HTTPS-aware trust configuration, or avoid switching `MasterInfo` to the HTTPS port until all its consumers are scheme/TLS aware. -- 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]
