xiangfu0 commented on code in PR #12462: URL: https://github.com/apache/pinot/pull/12462#discussion_r1499529185
########## pinot-common/src/main/java/org/apache/pinot/common/utils/tls/JvmDefaultSslContext.java: ########## @@ -0,0 +1,101 @@ +/** + * 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.pinot.common.utils.tls; + +import java.security.KeyStore; +import java.util.Optional; +import javax.net.ssl.SSLContext; +import nl.altindag.ssl.SSLFactory; +import org.apache.commons.lang.StringUtils; + + +public class JvmDefaultSslContext { + private static final String JVM_KEY_STORE = "javax.net.ssl.keyStore"; + private static final String JVM_KEY_STORE_TYPE = "javax.net.ssl.keyStoreType"; + private static final String JVM_KEY_STORE_PASSWORD = "javax.net.ssl.keyStorePassword"; + private static final String JVM_TRUST_STORE = "javax.net.ssl.trustStore"; + private static final String JVM_TRUST_STORE_TYPE = "javax.net.ssl.trustStoreType"; + private static final String JVM_TRUST_STORE_PASSWORD = "javax.net.ssl.trustStorePassword"; + + private static volatile boolean _initialized = false; + + private JvmDefaultSslContext() { + throw new IllegalStateException("Should not instantiate JvmDefaultSslContext"); + } + + /** + * Initialize the default SSL context based on the system properties. + * When either key store "javax.net.ssl.keyStore" or trust store "javax.net.ssl.trustStore" is specified in + * system property and they are files: + * set the default SSL context to the default SSL context created by SSLFactory, and enable auto renewal of + * SSLFactory when either key store or trust store file changes. + * TODO: need to support "javax.net.ssl.keyStoreProvider", "javax.net.ssl.trustStoreProvider", "https.protocols" and + * "https.cipherSuites" system properties. + */ + public static synchronized void initDefaultSslContext() { + if (_initialized) { + return; Review Comment: put a log, so we kind of know that this method is try to be called multiple places/ -- 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-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org