超媒网络 v3.0.0版本的 MD5 值为:e72248abb238993f421967424d9a9515
以下内容为反编译后的 OpenSsl.java 源代码,内容仅作参考
package io.netty.handler.ssl;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.internal.tcnative.Buffer;
import io.netty.internal.tcnative.CertificateCallback;
import io.netty.internal.tcnative.Library;
import io.netty.internal.tcnative.SSL;
import io.netty.internal.tcnative.SSLContext;
import io.netty.util.CharsetUtil;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.ReferenceCounted;
import io.netty.util.internal.NativeLibraryLoader;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.io.ByteArrayInputStream;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import p.a.y.e.a.s.e.net.r5;
public final class OpenSsl {
public static final boolean $assertionsDisabled = false;
public static final Set<String> AVAILABLE_CIPHER_SUITES;
private static final Set<String> AVAILABLE_JAVA_CIPHER_SUITES;
private static final Set<String> AVAILABLE_OPENSSL_CIPHER_SUITES;
private static final String CERT = "-----BEGIN CERTIFICATE-----\nMIICrjCCAZagAwIBAgIIdSvQPv1QAZQwDQYJKoZIhvcNAQELBQAwFjEUMBIGA1UEAxMLZXhhbXBs\nZS5jb20wIBcNMTgwNDA2MjIwNjU5WhgPOTk5OTEyMzEyMzU5NTlaMBYxFDASBgNVBAMTC2V4YW1w\nbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAggbWsmDQ6zNzRZ5AW8E3eoGl\nqWvOBDb5Fs1oBRrVQHuYmVAoaqwDzXYJ0LOwa293AgWEQ1jpcbZ2hpoYQzqEZBTLnFhMrhRFlH6K\nbJND8Y33kZ/iSVBBDuGbdSbJShlM+4WwQ9IAso4MZ4vW3S1iv5fGGpLgbtXRmBf/RU8omN0Gijlv\nWlLWHWijLN8xQtySFuBQ7ssW8RcKAary3pUm6UUQB+Co6lnfti0Tzag8PgjhAJq2Z3wbsGRnP2YS\nvYoaK6qzmHXRYlp/PxrjBAZAmkLJs4YTm/XFF+fkeYx4i9zqHbyone5yerRibsHaXZWLnUL+rFoe\nMdKvr0VS3sGmhQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQADQi441pKmXf9FvUV5EHU4v8nJT9Iq\nyqwsKwXnr7AsUlDGHBD7jGrjAXnG5rGxuNKBQ35wRxJATKrUtyaquFUL6H8O6aGQehiFTk6zmPbe\n12Gu44vqqTgIUxnv3JQJiox8S2hMxsSddpeCmSdvmalvD6WG4NthH6B9ZaBEiep1+0s0RUaBYn73\nI7CCUaAtbjfR6pcJjrFk5ei7uwdQZFSJtkP2z8r7zfeANJddAKFlkaMWn7u+OIVuB4XPooWicObk\nNAHFtP65bocUYnDpTVdiyvn8DdqyZ/EO8n1bBKBzuSLplk2msW4pdgaFgY7Vw/0wzcFXfUXmL1uy\nG8sQD/wx\n-----END CERTIFICATE-----";
public static final List<String> DEFAULT_CIPHERS;
private static final boolean IS_BORINGSSL;
private static final String KEY = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCCBtayYNDrM3NFnkBbwTd6gaWp\na84ENvkWzWgFGtVAe5iZUChqrAPNdgnQs7Brb3cCBYRDWOlxtnaGmhhDOoRkFMucWEyuFEWUfops\nk0PxjfeRn+JJUEEO4Zt1JslKGUz7hbBD0gCyjgxni9bdLWK/l8YakuBu1dGYF/9FTyiY3QaKOW9a\nUtYdaKMs3zFC3JIW4FDuyxbxFwoBqvLelSbpRRAH4KjqWd+2LRPNqDw+COEAmrZnfBuwZGc/ZhK9\nihorqrOYddFiWn8/GuMEBkCaQsmzhhOb9cUX5+R5jHiL3OodvKid7nJ6tGJuwdpdlYudQv6sWh4x\n0q+vRVLewaaFAgMBAAECggEAP8tPJvFtTxhNJAkCloHz0D0vpDHqQBMgntlkgayqmBqLwhyb18pR\ni0qwgh7HHc7wWqOOQuSqlEnrWRrdcI6TSe8R/sErzfTQNoznKWIPYcI/hskk4sdnQ//Yn9/Jvnsv\nU/BBjOTJxtD+sQbhAl80JcA3R+5sArURQkfzzHOL/YMqzAsn5hTzp7HZCxUqBk3KaHRxV7NefeOE\nxlZuWSmxYWfbFIs4kx19/1t7h8CHQWezw+G60G2VBtSBBxDnhBWvqG6R/wpzJ3nEhPLLY9T+XIHe\nipzdMOOOUZorfIg7M+pyYPji+ZIZxIpY5OjrOzXHciAjRtr5Y7l99K1CG1LguQKBgQDrQfIMxxtZ\nvxU/1cRmUV9l7pt5bjV5R6byXq178LxPKVYNjdZ840Q0/OpZEVqaT1xKVi35ohP1QfNjxPLlHD+K\niDAR9z6zkwjIrbwPCnb5kuXy4lpwPcmmmkva25fI7qlpHtbcuQdoBdCfr/KkKaUCMPyY89LCXgEw\n5KTDj64UywKBgQCNfbO+eZLGzhiHhtNJurresCsIGWlInv322gL8CSfBMYl6eNfUTZvUDdFhPISL\nUljKWzXDrjw0ujFSPR0XhUGtiq89H+HUTuPPYv25gVXO+HTgBFZEPl4PpA+BUsSVZy0NddneyqLk\n42Wey9omY9Q8WsdNQS5cbUvy0uG6WFoX7wKBgQDZ1jpW8pa0x2bZsQsm4vo+3G5CRnZlUp+XlWt2\ndDcp5dC0xD1zbs1dc0NcLeGDOTDv9FSl7hok42iHXXq8AygjEm/QcuwwQ1nC2HxmQP5holAiUs4D\nWHM8PWs3wFYPzE459EBoKTxeaeP/uWAn+he8q7d5uWvSZlEcANs/6e77eQKBgD21Ar0hfFfj7mK8\n9E0FeRZBsqK3omkfnhcYgZC11Xa2SgT1yvs2Va2n0RcdM5kncr3eBZav2GYOhhAdwyBM55XuE/sO\neokDVutNeuZ6d5fqV96TRaRBpvgfTvvRwxZ9hvKF4Vz+9wfn/JvCwANaKmegF6ejs7pvmF3whq2k\ndrZVAoGAX5YxQ5XMTD0QbMAl7/6qp6S58xNoVdfCkmkj1ZLKaHKIjS/benkKGlySVQVPexPfnkZx\np/Vv9yyphBoudiTBS9Uog66ueLYZqpgxlM/6OhYg86Gm3U2ycvMxYjBM1NFiyze21AqAhI+HX+Ot\nmraV2/guSgDgZAhukRZzeQ2RucI=\n-----END PRIVATE KEY-----";
public static final Set<String> SUPPORTED_PROTOCOLS_SET;
private static final boolean SUPPORTS_KEYMANAGER_FACTORY;
private static final boolean SUPPORTS_OCSP;
private static final boolean TLSV13_SUPPORTED;
private static final Throwable UNAVAILABILITY_CAUSE;
private static final boolean USE_KEYMANAGER_FACTORY;
private static final InternalLogger logger;
static {
Throwable th;
boolean z;
boolean z2;
boolean z3;
InternalLogger internalLogger;
boolean z4;
boolean z5;
long j;
long j2;
long j3;
long j4;
String[] ciphers;
long j5;
boolean z6;
boolean z7;
InternalLogger internalLoggerFactory = InternalLoggerFactory.getInstance(OpenSsl.class);
logger = internalLoggerFactory;
if (SystemPropertyUtil.getBoolean("io.netty.handler.ssl.noOpenSsl", false)) {
e = new UnsupportedOperationException("OpenSSL was explicit disabled with -Dio.netty.handler.ssl.noOpenSsl=true");
StringBuilder b = r5.b("netty-tcnative explicit disabled; ");
b.append(OpenSslEngine.class.getSimpleName());
b.append(" will be unavailable.");
internalLoggerFactory.debug(b.toString(), e);
} else {
try {
Class.forName("io.netty.internal.tcnative.SSL", false, OpenSsl.class.getClassLoader());
e = null;
} catch (ClassNotFoundException e) {
e = e;
InternalLogger internalLogger2 = logger;
StringBuilder b2 = r5.b("netty-tcnative not in the classpath; ");
b2.append(OpenSslEngine.class.getSimpleName());
b2.append(" will be unavailable.");
internalLogger2.debug(b2.toString());
}
if (e == null) {
try {
loadTcNative();
th = e;
} catch (Throwable th2) {
th = th2;
InternalLogger internalLogger3 = logger;
StringBuilder b3 = r5.b("Failed to load netty-tcnative; ");
b3.append(OpenSslEngine.class.getSimpleName());
b3.append(" will be unavailable, unless the application has already loaded the symbols by some other means. See https://netty.io/wiki/forked-tomcat-native.html for more information.");
internalLogger3.debug(b3.toString(), th);
}
try {
String str = SystemPropertyUtil.get("io.netty.handler.ssl.openssl.engine", null);
if (str == null) {
logger.debug("Initialize netty-tcnative using engine: 'default'");
} else {
logger.debug("Initialize netty-tcnative using engine: '{}'", str);
}
initializeTcNative(str);
e = null;
} catch (Throwable th3) {
if (th == null) {
th = th3;
}
InternalLogger internalLogger4 = logger;
StringBuilder b4 = r5.b("Failed to initialize netty-tcnative; ");
b4.append(OpenSslEngine.class.getSimpleName());
b4.append(" will be unavailable. See https://netty.io/wiki/forked-tomcat-native.html for more information.");
internalLogger4.debug(b4.toString(), th3);
e = th;
}
}
}
UNAVAILABILITY_CAUSE = e;
if (e == null) {
logger.debug("netty-tcnative using native library: {}", SSL.versionString());
ArrayList arrayList = new ArrayList();
LinkedHashSet linkedHashSet = new LinkedHashSet(128);
IS_BORINGSSL = "BoringSSL".equals(versionString());
try {
long make = SSLContext.make(63, 1);
try {
StringBuilder sb = new StringBuilder();
for (String str2 : SslUtils.TLSV13_CIPHERS) {
String openSsl = CipherSuiteConverter.toOpenSsl(str2, IS_BORINGSSL);
if (openSsl != null) {
sb.append(openSsl);
sb.append(':');
}
}
if (sb.length() == 0) {
z7 = false;
} else {
sb.setLength(sb.length() - 1);
SSLContext.setCipherSuite(make, sb.toString(), true);
z7 = true;
}
z3 = z7;
} catch (Exception unused) {
z3 = false;
} catch (Throwable th4) {
th = th4;
z4 = false;
z5 = false;
z3 = false;
try {
SSLContext.free(make);
throw th;
} catch (Exception e2) {
e = e2;
boolean z8 = z5;
z2 = z4;
z = z8;
logger.warn("Failed to get the list of available OpenSSL cipher suites.", (Throwable) e);
Set<String> unmodifiableSet = Collections.unmodifiableSet(linkedHashSet);
AVAILABLE_OPENSSL_CIPHER_SUITES = unmodifiableSet;
LinkedHashSet linkedHashSet2 = new LinkedHashSet(unmodifiableSet.size() * 2);
while (r0.hasNext()) {
}
SslUtils.addIfSupported(linkedHashSet2, arrayList, SslUtils.DEFAULT_CIPHER_SUITES);
SslUtils.addIfSupported(linkedHashSet2, arrayList, SslUtils.TLSV13_CIPHER_SUITES);
SslUtils.useFallbackCiphersIfDefaultIsEmpty(arrayList, linkedHashSet2);
List<String> unmodifiableList = Collections.unmodifiableList(arrayList);
DEFAULT_CIPHERS = unmodifiableList;
Set<String> unmodifiableSet2 = Collections.unmodifiableSet(linkedHashSet2);
AVAILABLE_JAVA_CIPHER_SUITES = unmodifiableSet2;
Set<String> set = AVAILABLE_OPENSSL_CIPHER_SUITES;
LinkedHashSet linkedHashSet3 = new LinkedHashSet(unmodifiableSet2.size() + set.size());
linkedHashSet3.addAll(set);
linkedHashSet3.addAll(unmodifiableSet2);
AVAILABLE_CIPHER_SUITES = linkedHashSet3;
SUPPORTS_KEYMANAGER_FACTORY = z;
USE_KEYMANAGER_FACTORY = z2;
LinkedHashSet linkedHashSet4 = new LinkedHashSet(6);
linkedHashSet4.add(SslUtils.PROTOCOL_SSL_V2_HELLO);
if (doesSupportProtocol(1, SSL.SSL_OP_NO_SSLv2)) {
}
if (doesSupportProtocol(2, SSL.SSL_OP_NO_SSLv3)) {
}
if (doesSupportProtocol(4, SSL.SSL_OP_NO_TLSv1)) {
}
if (doesSupportProtocol(8, SSL.SSL_OP_NO_TLSv1_1)) {
}
if (doesSupportProtocol(16, SSL.SSL_OP_NO_TLSv1_2)) {
}
if (!z3) {
}
TLSV13_SUPPORTED = false;
Set<String> unmodifiableSet3 = Collections.unmodifiableSet(linkedHashSet4);
SUPPORTED_PROTOCOLS_SET = unmodifiableSet3;
SUPPORTS_OCSP = doesSupportOcsp();
internalLogger = logger;
if (internalLogger.isDebugEnabled()) {
}
}
}
try {
SSLContext.setCipherSuite(make, "ALL", false);
long newSSL = SSL.newSSL(make, true);
try {
for (String str3 : SSL.getCiphers(newSSL)) {
if (str3 != null && !str3.isEmpty() && !linkedHashSet.contains(str3) && (z3 || !SslUtils.isTLSv13Cipher(str3))) {
linkedHashSet.add(str3);
}
}
boolean z9 = IS_BORINGSSL;
if (z9) {
Collections.addAll(linkedHashSet, "TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384", "TLS_CHACHA20_POLY1305_SHA256", "AEAD-AES128-GCM-SHA256", "AEAD-AES256-GCM-SHA384", "AEAD-CHACHA20-POLY1305-SHA256");
}
PemPrivateKey valueOf = PemPrivateKey.valueOf(KEY.getBytes(CharsetUtil.US_ASCII));
try {
SSLContext.setCertificateCallback(make, (CertificateCallback) null);
j2 = ReferenceCountedOpenSslContext.toBIO(ByteBufAllocator.DEFAULT, selfSignedCertificate());
try {
j3 = SSL.parseX509Chain(j2);
try {
long bio = ReferenceCountedOpenSslContext.toBIO(UnpooledByteBufAllocator.DEFAULT, valueOf.retain());
try {
j4 = SSL.parsePrivateKey(bio, (String) null);
j5 = bio;
try {
SSL.setKeyMaterial(newSSL, j3, j4);
try {
boolean contains = SystemPropertyUtil.contains("io.netty.handler.ssl.openssl.useKeyManagerFactory");
if (z9) {
if (contains) {
try {
logger.info("System property 'io.netty.handler.ssl.openssl.useKeyManagerFactory' is deprecated and will be ignored when using BoringSSL");
} catch (Throwable unused2) {
z4 = true;
logger.debug("Failed to get useKeyManagerFactory system property.");
valueOf.release();
z2 = z4;
j = j5;
z = true;
SSL.freeSSL(newSSL);
if (j2 != 0) {
}
if (j != 0) {
}
if (j3 != 0) {
}
if (j4 != 0) {
}
SSLContext.free(make);
Set<String> unmodifiableSet4 = Collections.unmodifiableSet(linkedHashSet);
AVAILABLE_OPENSSL_CIPHER_SUITES = unmodifiableSet4;
LinkedHashSet linkedHashSet22 = new LinkedHashSet(unmodifiableSet4.size() * 2);
while (r0.hasNext()) {
}
SslUtils.addIfSupported(linkedHashSet22, arrayList, SslUtils.DEFAULT_CIPHER_SUITES);
SslUtils.addIfSupported(linkedHashSet22, arrayList, SslUtils.TLSV13_CIPHER_SUITES);
SslUtils.useFallbackCiphersIfDefaultIsEmpty(arrayList, linkedHashSet22);
List<String> unmodifiableList2 = Collections.unmodifiableList(arrayList);
DEFAULT_CIPHERS = unmodifiableList2;
Set<String> unmodifiableSet22 = Collections.unmodifiableSet(linkedHashSet22);
AVAILABLE_JAVA_CIPHER_SUITES = unmodifiableSet22;
Set<String> set2 = AVAILABLE_OPENSSL_CIPHER_SUITES;
LinkedHashSet linkedHashSet32 = new LinkedHashSet(unmodifiableSet22.size() + set2.size());
linkedHashSet32.addAll(set2);
linkedHashSet32.addAll(unmodifiableSet22);
AVAILABLE_CIPHER_SUITES = linkedHashSet32;
SUPPORTS_KEYMANAGER_FACTORY = z;
USE_KEYMANAGER_FACTORY = z2;
LinkedHashSet linkedHashSet42 = new LinkedHashSet(6);
linkedHashSet42.add(SslUtils.PROTOCOL_SSL_V2_HELLO);
if (doesSupportProtocol(1, SSL.SSL_OP_NO_SSLv2)) {
}
if (doesSupportProtocol(2, SSL.SSL_OP_NO_SSLv3)) {
}
if (doesSupportProtocol(4, SSL.SSL_OP_NO_TLSv1)) {
}
if (doesSupportProtocol(8, SSL.SSL_OP_NO_TLSv1_1)) {
}
if (doesSupportProtocol(16, SSL.SSL_OP_NO_TLSv1_2)) {
}
if (!z3) {
}
TLSV13_SUPPORTED = false;
Set<String> unmodifiableSet32 = Collections.unmodifiableSet(linkedHashSet42);
SUPPORTED_PROTOCOLS_SET = unmodifiableSet32;
SUPPORTS_OCSP = doesSupportOcsp();
internalLogger = logger;
if (internalLogger.isDebugEnabled()) {
}
}
}
z6 = true;
} else {
z6 = SystemPropertyUtil.getBoolean("io.netty.handler.ssl.openssl.useKeyManagerFactory", true);
if (contains) {
try {
logger.info("System property 'io.netty.handler.ssl.openssl.useKeyManagerFactory' is deprecated and so will be ignored in the future");
} catch (Throwable unused3) {
z4 = z6;
try {
logger.debug("Failed to get useKeyManagerFactory system property.");
valueOf.release();
z2 = z4;
j = j5;
z = true;
} catch (Error unused4) {
z2 = z4;
j = j5;
z = true;
try {
logger.debug("KeyManagerFactory not supported.");
try {
valueOf.release();
SSL.freeSSL(newSSL);
if (j2 != 0) {
}
if (j != 0) {
}
if (j3 != 0) {
}
if (j4 != 0) {
}
SSLContext.free(make);
Set<String> unmodifiableSet42 = Collections.unmodifiableSet(linkedHashSet);
AVAILABLE_OPENSSL_CIPHER_SUITES = unmodifiableSet42;
LinkedHashSet linkedHashSet222 = new LinkedHashSet(unmodifiableSet42.size() * 2);
while (r0.hasNext()) {
}
SslUtils.addIfSupported(linkedHashSet222, arrayList, SslUtils.DEFAULT_CIPHER_SUITES);
SslUtils.addIfSupported(linkedHashSet222, arrayList, SslUtils.TLSV13_CIPHER_SUITES);
SslUtils.useFallbackCiphersIfDefaultIsEmpty(arrayList, linkedHashSet222);
List<String> unmodifiableList22 = Collections.unmodifiableList(arrayList);
DEFAULT_CIPHERS = unmodifiableList22;
Set<String> unmodifiableSet222 = Collections.unmodifiableSet(linkedHashSet222);
AVAILABLE_JAVA_CIPHER_SUITES = unmodifiableSet222;
Set<String> set22 = AVAILABLE_OPENSSL_CIPHER_SUITES;
LinkedHashSet linkedHashSet322 = new LinkedHashSet(unmodifiableSet222.size() + set22.size());
linkedHashSet322.addAll(set22);
linkedHashSet322.addAll(unmodifiableSet222);
AVAILABLE_CIPHER_SUITES = linkedHashSet322;
SUPPORTS_KEYMANAGER_FACTORY = z;
USE_KEYMANAGER_FACTORY = z2;
LinkedHashSet linkedHashSet422 = new LinkedHashSet(6);
linkedHashSet422.add(SslUtils.PROTOCOL_SSL_V2_HELLO);
if (doesSupportProtocol(1, SSL.SSL_OP_NO_SSLv2)) {
}
if (doesSupportProtocol(2, SSL.SSL_OP_NO_SSLv3)) {
}
if (doesSupportProtocol(4, SSL.SSL_OP_NO_TLSv1)) {
}
if (doesSupportProtocol(8, SSL.SSL_OP_NO_TLSv1_1)) {
}
if (doesSupportProtocol(16, SSL.SSL_OP_NO_TLSv1_2)) {
}
if (!z3) {
}
TLSV13_SUPPORTED = false;
Set<String> unmodifiableSet322 = Collections.unmodifiableSet(linkedHashSet422);
SUPPORTED_PROTOCOLS_SET = unmodifiableSet322;
SUPPORTS_OCSP = doesSupportOcsp();
internalLogger = logger;
if (internalLogger.isDebugEnabled()) {
}
} catch (Throwable th5) {
th = th5;
boolean z10 = z2;
z5 = z;
z4 = z10;
try {
SSL.freeSSL(newSSL);
if (j2 != 0) {
SSL.freeBIO(j2);
}
if (j != 0) {
SSL.freeBIO(j);
}
if (j3 != 0) {
SSL.freeX509Chain(j3);
}
if (j4 != 0) {
SSL.freePrivateKey(j4);
}
throw th;
} catch (Throwable th6) {
th = th6;
SSLContext.free(make);
throw th;
}
}
} catch (Throwable th7) {
th = th7;
boolean z11 = z2;
z5 = z;
z4 = z11;
try {
valueOf.release();
throw th;
} catch (Throwable th8) {
th = th8;
SSL.freeSSL(newSSL);
if (j2 != 0) {
}
if (j != 0) {
}
if (j3 != 0) {
}
if (j4 != 0) {
}
throw th;
}
}
} catch (Throwable th9) {
th = th9;
z5 = true;
j = j5;
valueOf.release();
throw th;
}
SSL.freeSSL(newSSL);
if (j2 != 0) {
}
if (j != 0) {
}
if (j3 != 0) {
}
if (j4 != 0) {
}
SSLContext.free(make);
Set<String> unmodifiableSet422 = Collections.unmodifiableSet(linkedHashSet);
AVAILABLE_OPENSSL_CIPHER_SUITES = unmodifiableSet422;
LinkedHashSet linkedHashSet2222 = new LinkedHashSet(unmodifiableSet422.size() * 2);
while (r0.hasNext()) {
}
SslUtils.addIfSupported(linkedHashSet2222, arrayList, SslUtils.DEFAULT_CIPHER_SUITES);
SslUtils.addIfSupported(linkedHashSet2222, arrayList, SslUtils.TLSV13_CIPHER_SUITES);
SslUtils.useFallbackCiphersIfDefaultIsEmpty(arrayList, linkedHashSet2222);
List<String> unmodifiableList222 = Collections.unmodifiableList(arrayList);
DEFAULT_CIPHERS = unmodifiableList222;
Set<String> unmodifiableSet2222 = Collections.unmodifiableSet(linkedHashSet2222);
AVAILABLE_JAVA_CIPHER_SUITES = unmodifiableSet2222;
Set<String> set222 = AVAILABLE_OPENSSL_CIPHER_SUITES;
LinkedHashSet linkedHashSet3222 = new LinkedHashSet(unmodifiableSet2222.size() + set222.size());
linkedHashSet3222.addAll(set222);
linkedHashSet3222.addAll(unmodifiableSet2222);
AVAILABLE_CIPHER_SUITES = linkedHashSet3222;
SUPPORTS_KEYMANAGER_FACTORY = z;
USE_KEYMANAGER_FACTORY = z2;
LinkedHashSet linkedHashSet4222 = new LinkedHashSet(6);
linkedHashSet4222.add(SslUtils.PROTOCOL_SSL_V2_HELLO);
if (doesSupportProtocol(1, SSL.SSL_OP_NO_SSLv2)) {
}
if (doesSupportProtocol(2, SSL.SSL_OP_NO_SSLv3)) {
}
if (doesSupportProtocol(4, SSL.SSL_OP_NO_TLSv1)) {
}
if (doesSupportProtocol(8, SSL.SSL_OP_NO_TLSv1_1)) {
}
if (doesSupportProtocol(16, SSL.SSL_OP_NO_TLSv1_2)) {
}
if (!z3) {
}
TLSV13_SUPPORTED = false;
Set<String> unmodifiableSet3222 = Collections.unmodifiableSet(linkedHashSet4222);
SUPPORTED_PROTOCOLS_SET = unmodifiableSet3222;
SUPPORTS_OCSP = doesSupportOcsp();
internalLogger = logger;
if (internalLogger.isDebugEnabled()) {
}
}
}
}
z4 = z6;
} catch (Throwable unused5) {
z4 = false;
}
try {
valueOf.release();
z2 = z4;
j = j5;
z = true;
} catch (Throwable th10) {
th = th10;
z5 = true;
j = j5;
SSL.freeSSL(newSSL);
if (j2 != 0) {
}
if (j != 0) {
}
if (j3 != 0) {
}
if (j4 != 0) {
}
throw th;
}
} catch (Error unused6) {
j = j5;
z = false;
z2 = false;
logger.debug("KeyManagerFactory not supported.");
valueOf.release();
SSL.freeSSL(newSSL);
if (j2 != 0) {
}
if (j != 0) {
}
if (j3 != 0) {
}
if (j4 != 0) {
}
SSLContext.free(make);
Set<String> unmodifiableSet4222 = Collections.unmodifiableSet(linkedHashSet);
AVAILABLE_OPENSSL_CIPHER_SUITES = unmodifiableSet4222;
LinkedHashSet linkedHashSet22222 = new LinkedHashSet(unmodifiableSet4222.size() * 2);
while (r0.hasNext()) {
}
SslUtils.addIfSupported(linkedHashSet22222, arrayList, SslUtils.DEFAULT_CIPHER_SUITES);
SslUtils.addIfSupported(linkedHashSet22222, arrayList, SslUtils.TLSV13_CIPHER_SUITES);
SslUtils.useFallbackCiphersIfDefaultIsEmpty(arrayList, linkedHashSet22222);
List<String> unmodifiableList2222 = Collections.unmodifiableList(arrayList);
DEFAULT_CIPHERS = unmodifiableList2222;
Set<String> unmodifiableSet22222 = Collections.unmodifiableSet(linkedHashSet22222);
AVAILABLE_JAVA_CIPHER_SUITES = unmodifiableSet22222;
Set<String> set2222 = AVAILABLE_OPENSSL_CIPHER_SUITES;
LinkedHashSet linkedHashSet32222 = new LinkedHashSet(unmodifiableSet22222.size() + set2222.size());
linkedHashSet32222.addAll(set2222);
linkedHashSet32222.addAll(unmodifiableSet22222);
AVAILABLE_CIPHER_SUITES = linkedHashSet32222;
SUPPORTS_KEYMANAGER_FACTORY = z;
USE_KEYMANAGER_FACTORY = z2;
LinkedHashSet linkedHashSet42222 = new LinkedHashSet(6);
linkedHashSet42222.add(SslUtils.PROTOCOL_SSL_V2_HELLO);
if (doesSupportProtocol(1, SSL.SSL_OP_NO_SSLv2)) {
}
if (doesSupportProtocol(2, SSL.SSL_OP_NO_SSLv3)) {
}
if (doesSupportProtocol(4, SSL.SSL_OP_NO_TLSv1)) {
}
if (doesSupportProtocol(8, SSL.SSL_OP_NO_TLSv1_1)) {
}
if (doesSupportProtocol(16, SSL.SSL_OP_NO_TLSv1_2)) {
}
if (!z3) {
}
TLSV13_SUPPORTED = false;
Set<String> unmodifiableSet32222 = Collections.unmodifiableSet(linkedHashSet42222);
SUPPORTED_PROTOCOLS_SET = unmodifiableSet32222;
SUPPORTS_OCSP = doesSupportOcsp();
internalLogger = logger;
if (internalLogger.isDebugEnabled()) {
}
} catch (Throwable th11) {
th = th11;
j = j5;
z4 = false;
z5 = false;
valueOf.release();
throw th;
}
} catch (Error unused7) {
j5 = bio;
j4 = 0;
} catch (Throwable th12) {
th = th12;
j5 = bio;
j4 = 0;
}
} catch (Error unused8) {
j = 0;
j4 = 0;
} catch (Throwable th13) {
th = th13;
j = 0;
j4 = 0;
}
} catch (Error unused9) {
j = 0;
j3 = 0;
j4 = 0;
z = false;
z2 = false;
logger.debug("KeyManagerFactory not supported.");
valueOf.release();
SSL.freeSSL(newSSL);
if (j2 != 0) {
}
if (j != 0) {
}
if (j3 != 0) {
}
if (j4 != 0) {
}
SSLContext.free(make);
Set<String> unmodifiableSet42222 = Collections.unmodifiableSet(linkedHashSet);
AVAILABLE_OPENSSL_CIPHER_SUITES = unmodifiableSet42222;
LinkedHashSet linkedHashSet222222 = new LinkedHashSet(unmodifiableSet42222.size() * 2);
while (r0.hasNext()) {
}
SslUtils.addIfSupported(linkedHashSet222222, arrayList, SslUtils.DEFAULT_CIPHER_SUITES);
SslUtils.addIfSupported(linkedHashSet222222, arrayList, SslUtils.TLSV13_CIPHER_SUITES);
SslUtils.useFallbackCiphersIfDefaultIsEmpty(arrayList, linkedHashSet222222);
List<String> unmodifiableList22222 = Collections.unmodifiableList(arrayList);
DEFAULT_CIPHERS = unmodifiableList22222;
Set<String> unmodifiableSet222222 = Collections.unmodifiableSet(linkedHashSet222222);
AVAILABLE_JAVA_CIPHER_SUITES = unmodifiableSet222222;
Set<String> set22222 = AVAILABLE_OPENSSL_CIPHER_SUITES;
LinkedHashSet linkedHashSet322222 = new LinkedHashSet(unmodifiableSet222222.size() + set22222.size());
linkedHashSet322222.addAll(set22222);
linkedHashSet322222.addAll(unmodifiableSet222222);
AVAILABLE_CIPHER_SUITES = linkedHashSet322222;
SUPPORTS_KEYMANAGER_FACTORY = z;
USE_KEYMANAGER_FACTORY = z2;
LinkedHashSet linkedHashSet422222 = new LinkedHashSet(6);
linkedHashSet422222.add(SslUtils.PROTOCOL_SSL_V2_HELLO);
if (doesSupportProtocol(1, SSL.SSL_OP_NO_SSLv2)) {
}
if (doesSupportProtocol(2, SSL.SSL_OP_NO_SSLv3)) {
}
if (doesSupportProtocol(4, SSL.SSL_OP_NO_TLSv1)) {
}
if (doesSupportProtocol(8, SSL.SSL_OP_NO_TLSv1_1)) {
}
if (doesSupportProtocol(16, SSL.SSL_OP_NO_TLSv1_2)) {
}
if (!z3) {
}
TLSV13_SUPPORTED = false;
Set<String> unmodifiableSet322222 = Collections.unmodifiableSet(linkedHashSet422222);
SUPPORTED_PROTOCOLS_SET = unmodifiableSet322222;
SUPPORTS_OCSP = doesSupportOcsp();
internalLogger = logger;
if (internalLogger.isDebugEnabled()) {
}
} catch (Throwable th14) {
th = th14;
j = 0;
j3 = 0;
j4 = 0;
z4 = false;
z5 = false;
valueOf.release();
throw th;
}
} catch (Error unused10) {
j2 = 0;
} catch (Throwable th15) {
th = th15;
j2 = 0;
}
try {
SSL.freeSSL(newSSL);
if (j2 != 0) {
SSL.freeBIO(j2);
}
if (j != 0) {
SSL.freeBIO(j);
}
if (j3 != 0) {
SSL.freeX509Chain(j3);
}
if (j4 != 0) {
SSL.freePrivateKey(j4);
}
SSLContext.free(make);
} catch (Throwable th16) {
th = th16;
boolean z12 = z2;
z5 = z;
z4 = z12;
SSLContext.free(make);
throw th;
}
} catch (Throwable th17) {
th = th17;
z4 = false;
z5 = false;
j = 0;
j2 = 0;
j3 = 0;
j4 = 0;
}
} catch (Throwable th18) {
th = th18;
z4 = false;
z5 = false;
}
} catch (Exception e3) {
e = e3;
z = false;
z2 = false;
z3 = false;
}
Set<String> unmodifiableSet422222 = Collections.unmodifiableSet(linkedHashSet);
AVAILABLE_OPENSSL_CIPHER_SUITES = unmodifiableSet422222;
LinkedHashSet linkedHashSet2222222 = new LinkedHashSet(unmodifiableSet422222.size() * 2);
for (String str4 : unmodifiableSet422222) {
if (!SslUtils.isTLSv13Cipher(str4)) {
linkedHashSet2222222.add(CipherSuiteConverter.toJava(str4, JdkSslContext.PROTOCOL));
linkedHashSet2222222.add(CipherSuiteConverter.toJava(str4, "SSL"));
} else {
linkedHashSet2222222.add(str4);
}
}
SslUtils.addIfSupported(linkedHashSet2222222, arrayList, SslUtils.DEFAULT_CIPHER_SUITES);
SslUtils.addIfSupported(linkedHashSet2222222, arrayList, SslUtils.TLSV13_CIPHER_SUITES);
SslUtils.useFallbackCiphersIfDefaultIsEmpty(arrayList, linkedHashSet2222222);
List<String> unmodifiableList222222 = Collections.unmodifiableList(arrayList);
DEFAULT_CIPHERS = unmodifiableList222222;
Set<String> unmodifiableSet2222222 = Collections.unmodifiableSet(linkedHashSet2222222);
AVAILABLE_JAVA_CIPHER_SUITES = unmodifiableSet2222222;
Set<String> set222222 = AVAILABLE_OPENSSL_CIPHER_SUITES;
LinkedHashSet linkedHashSet3222222 = new LinkedHashSet(unmodifiableSet2222222.size() + set222222.size());
linkedHashSet3222222.addAll(set222222);
linkedHashSet3222222.addAll(unmodifiableSet2222222);
AVAILABLE_CIPHER_SUITES = linkedHashSet3222222;
SUPPORTS_KEYMANAGER_FACTORY = z;
USE_KEYMANAGER_FACTORY = z2;
LinkedHashSet linkedHashSet4222222 = new LinkedHashSet(6);
linkedHashSet4222222.add(SslUtils.PROTOCOL_SSL_V2_HELLO);
if (doesSupportProtocol(1, SSL.SSL_OP_NO_SSLv2)) {
linkedHashSet4222222.add(SslUtils.PROTOCOL_SSL_V2);
}
if (doesSupportProtocol(2, SSL.SSL_OP_NO_SSLv3)) {
linkedHashSet4222222.add(SslUtils.PROTOCOL_SSL_V3);
}
if (doesSupportProtocol(4, SSL.SSL_OP_NO_TLSv1)) {
linkedHashSet4222222.add(SslUtils.PROTOCOL_TLS_V1);
}
if (doesSupportProtocol(8, SSL.SSL_OP_NO_TLSv1_1)) {
linkedHashSet4222222.add(SslUtils.PROTOCOL_TLS_V1_1);
}
if (doesSupportProtocol(16, SSL.SSL_OP_NO_TLSv1_2)) {
linkedHashSet4222222.add(SslUtils.PROTOCOL_TLS_V1_2);
}
if (!z3 && doesSupportProtocol(32, SSL.SSL_OP_NO_TLSv1_3)) {
linkedHashSet4222222.add(SslUtils.PROTOCOL_TLS_V1_3);
TLSV13_SUPPORTED = true;
} else {
TLSV13_SUPPORTED = false;
}
Set<String> unmodifiableSet3222222 = Collections.unmodifiableSet(linkedHashSet4222222);
SUPPORTED_PROTOCOLS_SET = unmodifiableSet3222222;
SUPPORTS_OCSP = doesSupportOcsp();
internalLogger = logger;
if (internalLogger.isDebugEnabled()) {
return;
}
internalLogger.debug("Supported protocols (OpenSSL): {} ", unmodifiableSet3222222);
internalLogger.debug("Default cipher suites (OpenSSL): {}", unmodifiableList222222);
return;
}
DEFAULT_CIPHERS = Collections.emptyList();
AVAILABLE_OPENSSL_CIPHER_SUITES = Collections.emptySet();
AVAILABLE_JAVA_CIPHER_SUITES = Collections.emptySet();
AVAILABLE_CIPHER_SUITES = Collections.emptySet();
SUPPORTS_KEYMANAGER_FACTORY = false;
USE_KEYMANAGER_FACTORY = false;
SUPPORTED_PROTOCOLS_SET = Collections.emptySet();
SUPPORTS_OCSP = false;
TLSV13_SUPPORTED = false;
IS_BORINGSSL = false;
}
private OpenSsl() {
}
@Deprecated
public static Set<String> availableCipherSuites() {
return availableOpenSslCipherSuites();
}
public static Set<String> availableJavaCipherSuites() {
return AVAILABLE_JAVA_CIPHER_SUITES;
}
public static Set<String> availableOpenSslCipherSuites() {
return AVAILABLE_OPENSSL_CIPHER_SUITES;
}
private static boolean doesSupportOcsp() {
long j;
if (version() >= 268443648) {
try {
j = SSLContext.make(16, 1);
try {
SSLContext.enableOcsp(j, false);
if (j != -1) {
SSLContext.free(j);
return true;
}
return true;
} catch (Exception unused) {
if (j != -1) {
SSLContext.free(j);
}
return false;
} catch (Throwable th) {
th = th;
if (j != -1) {
SSLContext.free(j);
}
throw th;
}
} catch (Exception unused2) {
j = -1;
} catch (Throwable th2) {
th = th2;
j = -1;
}
}
return false;
}
private static boolean doesSupportProtocol(int i, int i2) {
if (i2 == 0) {
return false;
}
try {
long make = SSLContext.make(i, 2);
if (make != -1) {
SSLContext.free(make);
}
return true;
} catch (Exception unused) {
return false;
}
}
public static void ensureAvailability() {
Throwable th = UNAVAILABILITY_CAUSE;
if (th != null) {
throw ((Error) new UnsatisfiedLinkError("failed to load the required native library").initCause(th));
}
}
private static boolean initializeTcNative(String str) throws Exception {
return Library.initialize("provided", str);
}
@Deprecated
public static boolean isAlpnSupported() {
return ((long) version()) >= 268443648;
}
public static boolean isAvailable() {
return UNAVAILABILITY_CAUSE == null;
}
public static boolean isBoringSSL() {
return IS_BORINGSSL;
}
public static boolean isCipherSuiteAvailable(String str) {
String openSsl = CipherSuiteConverter.toOpenSsl(str, IS_BORINGSSL);
if (openSsl != null) {
str = openSsl;
}
return AVAILABLE_OPENSSL_CIPHER_SUITES.contains(str);
}
public static boolean isOcspSupported() {
return SUPPORTS_OCSP;
}
public static boolean isTlsv13Supported() {
return TLSV13_SUPPORTED;
}
private static void loadTcNative() throws Exception {
String normalizedOs = PlatformDependent.normalizedOs();
String normalizedArch = PlatformDependent.normalizedArch();
LinkedHashSet linkedHashSet = new LinkedHashSet(5);
if ("linux".equalsIgnoreCase(normalizedOs)) {
Iterator<String> it = PlatformDependent.normalizedLinuxClassifiers().iterator();
while (it.hasNext()) {
linkedHashSet.add("netty_tcnative_" + normalizedOs + '_' + normalizedArch + "_" + it.next());
}
linkedHashSet.add("netty_tcnative_" + normalizedOs + '_' + normalizedArch);
linkedHashSet.add("netty_tcnative_" + normalizedOs + '_' + normalizedArch + "_fedora");
} else {
linkedHashSet.add("netty_tcnative_" + normalizedOs + '_' + normalizedArch);
}
linkedHashSet.add("netty_tcnative_" + normalizedArch);
linkedHashSet.add("netty_tcnative");
NativeLibraryLoader.loadFirstAvailable(SSL.class.getClassLoader(), (String[]) linkedHashSet.toArray(new String[0]));
}
public static long memoryAddress(ByteBuf byteBuf) {
return byteBuf.hasMemoryAddress() ? byteBuf.memoryAddress() : Buffer.address(byteBuf.nioBuffer());
}
public static void releaseIfNeeded(ReferenceCounted referenceCounted) {
if (referenceCounted.refCnt() > 0) {
ReferenceCountUtil.safeRelease(referenceCounted);
}
}
public static X509Certificate selfSignedCertificate() throws CertificateException {
return (X509Certificate) SslContext.X509_CERT_FACTORY.generateCertificate(new ByteArrayInputStream(CERT.getBytes(CharsetUtil.US_ASCII)));
}
@Deprecated
public static boolean supportsHostnameValidation() {
return isAvailable();
}
public static boolean supportsKeyManagerFactory() {
return SUPPORTS_KEYMANAGER_FACTORY;
}
public static Throwable unavailabilityCause() {
return UNAVAILABILITY_CAUSE;
}
public static boolean useKeyManagerFactory() {
return USE_KEYMANAGER_FACTORY;
}
public static int version() {
if (isAvailable()) {
return SSL.version();
}
return -1;
}
public static String versionString() {
if (isAvailable()) {
return SSL.versionString();
}
return null;
}
}