package org.apache.http.conn.ssl; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketTimeoutException; import java.net.UnknownHostException; import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import javax.net.SocketFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import o.C15239gkz; import o.C15266glu; import o.C15267glv; import o.InterfaceC15207gkA; import o.InterfaceC15209gkK; import o.gkC; import o.gkD; import o.gkE; import o.gkH; import o.gkL; import o.gkM; import org.apache.http.conn.ConnectTimeoutException; @Deprecated /* loaded from: classes6.dex */ public class SSLSocketFactory { public static final String SSL = "SSL"; public static final String SSLV2 = "SSLv2"; public static final String TLS = "TLS"; private final InterfaceC15207gkA a; private final javax.net.ssl.SSLSocketFactory b; private final String[] c; private final String[] d; private volatile X509HostnameVerifier e; public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER = new gkE(); public static final X509HostnameVerifier BROWSER_COMPATIBLE_HOSTNAME_VERIFIER = new BrowserCompatHostnameVerifier(); public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER = new StrictHostnameVerifier(); public static SSLSocketFactory getSocketFactory() throws SSLInitializationException { return new SSLSocketFactory(gkH.b(), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); } private static String[] c(String str) { if (C15266glu.b(str)) { return null; } return str.split(" *, *"); } public static SSLSocketFactory getSystemSocketFactory() throws SSLInitializationException { return new SSLSocketFactory((javax.net.ssl.SSLSocketFactory) javax.net.ssl.SSLSocketFactory.getDefault(), c(System.getProperty("https.protocols")), c(System.getProperty("https.cipherSuites")), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); } public SSLSocketFactory(SSLContext sSLContext) { this(sSLContext, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); } public SSLSocketFactory(SSLContext sSLContext, InterfaceC15207gkA interfaceC15207gkA) { this.b = sSLContext.getSocketFactory(); this.e = BROWSER_COMPATIBLE_HOSTNAME_VERIFIER; this.a = interfaceC15207gkA; this.d = null; this.c = null; } public SSLSocketFactory(SSLContext sSLContext, X509HostnameVerifier x509HostnameVerifier) { this(((SSLContext) C15267glv.b(sSLContext, "SSL context")).getSocketFactory(), (String[]) null, (String[]) null, x509HostnameVerifier); } public SSLSocketFactory(SSLContext sSLContext, String[] strArr, String[] strArr2, X509HostnameVerifier x509HostnameVerifier) { this(((SSLContext) C15267glv.b(sSLContext, "SSL context")).getSocketFactory(), strArr, strArr2, x509HostnameVerifier); } public SSLSocketFactory(javax.net.ssl.SSLSocketFactory sSLSocketFactory, X509HostnameVerifier x509HostnameVerifier) { this(sSLSocketFactory, (String[]) null, (String[]) null, x509HostnameVerifier); } public SSLSocketFactory(javax.net.ssl.SSLSocketFactory sSLSocketFactory, String[] strArr, String[] strArr2, X509HostnameVerifier x509HostnameVerifier) { this.b = (javax.net.ssl.SSLSocketFactory) C15267glv.b(sSLSocketFactory, "SSL socket factory"); this.d = strArr; this.c = strArr2; this.e = x509HostnameVerifier == null ? BROWSER_COMPATIBLE_HOSTNAME_VERIFIER : x509HostnameVerifier; this.a = null; } public Socket createSocket(gkM gkm) throws IOException { return createSocket((InterfaceC15209gkK) null); } public Socket createSocket() throws IOException { return createSocket((InterfaceC15209gkK) null); } public Socket connectSocket(Socket socket, InetSocketAddress inetSocketAddress, InetSocketAddress inetSocketAddress2, gkM gkm) throws IOException, UnknownHostException, ConnectTimeoutException { gkC gkc; C15267glv.b(inetSocketAddress, "Remote address"); C15267glv.b(gkm, "HTTP parameters"); if (!(inetSocketAddress instanceof C15239gkz)) { gkc = new gkC(inetSocketAddress.getHostName(), inetSocketAddress.getPort(), "https"); } else { gkc = ((C15239gkz) inetSocketAddress).a; } gkC gkc2 = gkc; C15267glv.b(gkm, "HTTP parameters"); int e = gkm.e(); C15267glv.b(gkm, "HTTP parameters"); int e2 = gkm.e(); socket.setSoTimeout(e); return connectSocket(e2, socket, gkc2, inetSocketAddress, inetSocketAddress2, (InterfaceC15209gkK) null); } public boolean isSecure(Socket socket) throws IllegalArgumentException { C15267glv.b(socket, "Socket"); if (socket instanceof SSLSocket) { if (!socket.isClosed()) { return true; } throw new IllegalStateException("Socket is closed"); } throw new IllegalStateException("Socket not created by this factory"); } public Socket createLayeredSocket(Socket socket, String str, int i, gkM gkm) throws IOException, UnknownHostException { return createLayeredSocket(socket, str, i, (InterfaceC15209gkK) null); } public Socket createLayeredSocket(Socket socket, String str, int i, boolean z) throws IOException, UnknownHostException { return createLayeredSocket(socket, str, i, (InterfaceC15209gkK) null); } public void setHostnameVerifier(X509HostnameVerifier x509HostnameVerifier) { C15267glv.b(x509HostnameVerifier, "Hostname verifier"); this.e = x509HostnameVerifier; } public Socket connectSocket(Socket socket, String str, int i, InetAddress inetAddress, int i2, gkM gkm) throws IOException, UnknownHostException, ConnectTimeoutException { InetAddress byName; InetSocketAddress inetSocketAddress; InterfaceC15207gkA interfaceC15207gkA = this.a; if (interfaceC15207gkA != null) { byName = interfaceC15207gkA.c(); } else { byName = InetAddress.getByName(str); } if (inetAddress != null || i2 > 0) { if (i2 <= 0) { i2 = 0; } inetSocketAddress = new InetSocketAddress(inetAddress, i2); } else { inetSocketAddress = null; } return connectSocket(socket, new C15239gkz(new gkC(str, i), byName, i), inetSocketAddress, gkm); } public Socket createSocket(Socket socket, String str, int i, boolean z) throws IOException, UnknownHostException { return createLayeredSocket(socket, str, i, z); } public Socket createSocket(InterfaceC15209gkK interfaceC15209gkK) throws IOException { return SocketFactory.getDefault().createSocket(); } public Socket connectSocket(int i, Socket socket, gkC gkc, InetSocketAddress inetSocketAddress, InetSocketAddress inetSocketAddress2, InterfaceC15209gkK interfaceC15209gkK) throws IOException { C15267glv.b(gkc, "HTTP host"); C15267glv.b(inetSocketAddress, "Remote address"); if (socket == null) { socket = createSocket(interfaceC15209gkK); } if (inetSocketAddress2 != null) { socket.bind(inetSocketAddress2); } try { socket.connect(inetSocketAddress, i); if (socket instanceof SSLSocket) { SSLSocket sSLSocket = (SSLSocket) socket; sSLSocket.startHandshake(); try { this.e.verify(gkc.a, sSLSocket); return socket; } catch (IOException e) { try { sSLSocket.close(); } catch (Exception unused) { } throw e; } } return createLayeredSocket(socket, gkc.a, inetSocketAddress.getPort(), interfaceC15209gkK); } catch (SocketTimeoutException unused2) { StringBuilder sb = new StringBuilder("Connect to "); sb.append(inetSocketAddress); sb.append(" timed out"); throw new ConnectTimeoutException(sb.toString()); } } public Socket createLayeredSocket(Socket socket, String str, int i, InterfaceC15209gkK interfaceC15209gkK) throws IOException { SSLSocket sSLSocket = (SSLSocket) this.b.createSocket(socket, str, i, true); String[] strArr = this.d; if (strArr != null) { sSLSocket.setEnabledProtocols(strArr); } String[] strArr2 = this.c; if (strArr2 != null) { sSLSocket.setEnabledCipherSuites(strArr2); } sSLSocket.startHandshake(); try { this.e.verify(str, sSLSocket); return sSLSocket; } catch (IOException e) { try { sSLSocket.close(); } catch (Exception unused) { } throw e; } } /* JADX WARN: Illegal instructions before constructor call */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public SSLSocketFactory(java.lang.String r2, java.security.KeyStore r3, java.lang.String r4, java.security.KeyStore r5, java.security.SecureRandom r6, o.InterfaceC15207gkA r7) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException, java.security.KeyStoreException, java.security.UnrecoverableKeyException { /* r1 = this; o.gkD r0 = new o.gkD r0.() r0.c = r2 r0.d = r6 if (r4 == 0) goto L10 char[] r2 = r4.toCharArray() goto L11 L10: r2 = 0 L11: o.gkD r2 = r0.e(r3, r2) o.gkD r2 = r2.a(r5) javax.net.ssl.SSLContext r2 = r2.b() r1.(r2, r7) return */ throw new UnsupportedOperationException("Method not decompiled: org.apache.http.conn.ssl.SSLSocketFactory.(java.lang.String, java.security.KeyStore, java.lang.String, java.security.KeyStore, java.security.SecureRandom, o.gkA):void"); } /* JADX WARN: Illegal instructions before constructor call */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public SSLSocketFactory(java.lang.String r2, java.security.KeyStore r3, java.lang.String r4, java.security.KeyStore r5, java.security.SecureRandom r6, o.gkL r7, org.apache.http.conn.ssl.X509HostnameVerifier r8) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException, java.security.KeyStoreException, java.security.UnrecoverableKeyException { /* r1 = this; o.gkD r0 = new o.gkD r0.() r0.c = r2 r0.d = r6 if (r4 == 0) goto L10 char[] r2 = r4.toCharArray() goto L11 L10: r2 = 0 L11: o.gkD r2 = r0.e(r3, r2) o.gkD r2 = r2.e(r5, r7) javax.net.ssl.SSLContext r2 = r2.b() r1.(r2, r8) return */ throw new UnsupportedOperationException("Method not decompiled: org.apache.http.conn.ssl.SSLSocketFactory.(java.lang.String, java.security.KeyStore, java.lang.String, java.security.KeyStore, java.security.SecureRandom, o.gkL, org.apache.http.conn.ssl.X509HostnameVerifier):void"); } /* JADX WARN: Illegal instructions before constructor call */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public SSLSocketFactory(java.lang.String r2, java.security.KeyStore r3, java.lang.String r4, java.security.KeyStore r5, java.security.SecureRandom r6, org.apache.http.conn.ssl.X509HostnameVerifier r7) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException, java.security.KeyStoreException, java.security.UnrecoverableKeyException { /* r1 = this; o.gkD r0 = new o.gkD r0.() r0.c = r2 r0.d = r6 if (r4 == 0) goto L10 char[] r2 = r4.toCharArray() goto L11 L10: r2 = 0 L11: o.gkD r2 = r0.e(r3, r2) o.gkD r2 = r2.a(r5) javax.net.ssl.SSLContext r2 = r2.b() r1.(r2, r7) return */ throw new UnsupportedOperationException("Method not decompiled: org.apache.http.conn.ssl.SSLSocketFactory.(java.lang.String, java.security.KeyStore, java.lang.String, java.security.KeyStore, java.security.SecureRandom, org.apache.http.conn.ssl.X509HostnameVerifier):void"); } public SSLSocketFactory(KeyStore keyStore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(new gkD().a(keyStore).b(), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); } public SSLSocketFactory(KeyStore keyStore, String str) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(new gkD().e(keyStore, str != null ? str.toCharArray() : null).b(), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); } public SSLSocketFactory(KeyStore keyStore, String str, KeyStore keyStore2) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(new gkD().e(keyStore, str != null ? str.toCharArray() : null).a(keyStore2).b(), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); } public SSLSocketFactory(gkL gkl) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(new gkD().e((KeyStore) null, gkl).b(), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); } public SSLSocketFactory(gkL gkl, X509HostnameVerifier x509HostnameVerifier) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { this(new gkD().e((KeyStore) null, gkl).b(), x509HostnameVerifier); } public X509HostnameVerifier getHostnameVerifier() { return this.e; } }