package csdk.glucentralservices.network; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; /* loaded from: classes4.dex */ public class GluTLS12SocketFactory extends SSLSocketFactory { private final SSLSocketFactory delegate; private static final Object contextLock = new Object(); private static final String[] SUPPORTED_PROTOCOLS = {"TLSv1.2"}; private static SSLContext sslContext = null; @Nullable public static GluTLS12SocketFactory createGluTLS12SocketFactory(@Nullable SSLContext sSLContext) { return null; } public static void fixTLSPre21(@NonNull HttpsURLConnection httpsURLConnection, @Nullable GluTLS12SocketFactory gluTLS12SocketFactory) { } @Nullable public static GluTLS12SocketFactory createGluTLS12SocketFactory() { return createGluTLS12SocketFactory(null); } public static void fixTLSPre21(@NonNull HttpsURLConnection httpsURLConnection) { fixTLSPre21(httpsURLConnection, createGluTLS12SocketFactory()); } private GluTLS12SocketFactory(@Nullable SSLContext sSLContext) throws KeyManagementException, NoSuchAlgorithmException { if (sSLContext != null) { this.delegate = sSLContext.getSocketFactory(); return; } synchronized (contextLock) { try { if (sslContext == null) { SSLContext sSLContext2 = SSLContext.getInstance("TLS"); sslContext = sSLContext2; sSLContext2.init(null, null, null); } } catch (Throwable th) { throw th; } } this.delegate = sslContext.getSocketFactory(); } @Override // javax.net.ssl.SSLSocketFactory public String[] getDefaultCipherSuites() { return this.delegate.getDefaultCipherSuites(); } @Override // javax.net.ssl.SSLSocketFactory public String[] getSupportedCipherSuites() { return this.delegate.getSupportedCipherSuites(); } @Override // javax.net.SocketFactory public Socket createSocket() throws IOException { return updateTLSProtocols((SSLSocket) this.delegate.createSocket()); } @Override // javax.net.ssl.SSLSocketFactory public Socket createSocket(Socket socket, String str, int i, boolean z) throws IOException { return updateTLSProtocols((SSLSocket) this.delegate.createSocket(socket, str, i, z)); } @Override // javax.net.SocketFactory public Socket createSocket(String str, int i) throws IOException, UnknownHostException { return updateTLSProtocols((SSLSocket) this.delegate.createSocket(str, i)); } @Override // javax.net.SocketFactory public Socket createSocket(String str, int i, InetAddress inetAddress, int i2) throws IOException, UnknownHostException { return updateTLSProtocols((SSLSocket) this.delegate.createSocket(str, i, inetAddress, i2)); } @Override // javax.net.SocketFactory public Socket createSocket(InetAddress inetAddress, int i) throws IOException { return updateTLSProtocols((SSLSocket) this.delegate.createSocket(inetAddress, i)); } @Override // javax.net.SocketFactory public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress2, int i2) throws IOException { return updateTLSProtocols((SSLSocket) this.delegate.createSocket(inetAddress, i, inetAddress2, i2)); } private Socket updateTLSProtocols(Socket socket) { if (socket instanceof SSLSocket) { try { ((SSLSocket) socket).setEnabledProtocols(SUPPORTED_PROTOCOLS); } catch (Exception unused) { } } return socket; } }