All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.palantir.dialogue.hc5.TlsProtocols Maven / Gradle / Ivy

/*
 * (c) Copyright 2021 Palantir Technologies Inc. All rights reserved.
 *
 * Licensed 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 com.palantir.dialogue.hc5;

import java.lang.Runtime.Version;

/** Internal utility functionality to slowly roll out new TLS protocol support. */
final class TlsProtocols {

    private static final boolean HAS_BUGGY_TLS_1_3 = hasKnownBuggyTls13();
    private static final String TLS_V1_2 = "TLSv1.2";
    private static final String TLS_V1_3 = "TLSv1.3";

    static String[] get() {
        if (HAS_BUGGY_TLS_1_3) {
            return new String[] {TLS_V1_2};
        } else {
            return new String[] {TLS_V1_3, TLS_V1_2};
        }
    }

    private static boolean hasKnownBuggyTls13() {
        // https://webtide.com/openjdk-11-and-tls-1-3-issues/
        // https://bugs.openjdk.java.net/browse/JDK-8213202
        // backported to jdk11.0.3 in https://bugs.openjdk.java.net/browse/JDK-8218094
        Version version = Runtime.version();
        return version.feature() == 11 && version.interim() == 0 && version.update() < 3;
    }

    private TlsProtocols() {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy