package p447;

import java.io.IOException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import kotlin.jvm.internal.DefaultConstructorMarker;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p242.p246.p251.C4303;
import p402.InterfaceC6538;
import p402.InterfaceC6540;
import p402.p403.C6563;
import p402.p411.p412.InterfaceC6603;
import p402.p411.p413.AbstractC6636;
import p402.p411.p413.C6635;
import p447.p448.C6943;

/* JADX INFO: renamed from: ސ.ޒ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@InterfaceC6540
public final class C6901 {

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public static final C6902 f20001 = new C6902(null);

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final InterfaceC6538 f20002;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final EnumC6939 f20003;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final C6876 f20004;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final List<Certificate> f20005;

    /* JADX INFO: renamed from: ސ.ޒ$֏, reason: contains not printable characters */
    @InterfaceC6540
    public static final class C6902 {

        /* JADX INFO: renamed from: ސ.ޒ$֏$֏, reason: contains not printable characters */
        public static final class C6903 extends AbstractC6636 implements InterfaceC6603<List<? extends Certificate>> {

            /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
            public final /* synthetic */ List f20006;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public C6903(List list) {
                super(0);
                this.f20006 = list;
            }

            @Override // p402.p411.p412.InterfaceC6603
            /* JADX INFO: renamed from: ނ */
            public List<? extends Certificate> mo1543() {
                return this.f20006;
            }
        }

        public C6902() {
        }

        public /* synthetic */ C6902(DefaultConstructorMarker defaultConstructorMarker) {
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final C6901 m10066(SSLSession sSLSession) throws IOException {
            List listM10160;
            if (sSLSession == null) {
                C6635.m9824("$this$handshake");
                throw null;
            }
            String cipherSuite = sSLSession.getCipherSuite();
            if (cipherSuite == null) {
                throw new IllegalStateException("cipherSuite == null".toString());
            }
            int iHashCode = cipherSuite.hashCode();
            if (iHashCode == 1019404634 ? cipherSuite.equals("TLS_NULL_WITH_NULL_NULL") : iHashCode == 1208658923 && cipherSuite.equals("SSL_NULL_WITH_NULL_NULL")) {
                throw new IOException(C2803.m4879("cipherSuite == ", cipherSuite));
            }
            C6876 c6876M10034 = C6876.f19956.m10034(cipherSuite);
            String protocol = sSLSession.getProtocol();
            if (protocol == null) {
                throw new IllegalStateException("tlsVersion == null".toString());
            }
            if (C6635.m9825((Object) "NONE", (Object) protocol)) {
                throw new IOException("tlsVersion == NONE");
            }
            EnumC6939 enumC6939M10140 = EnumC6939.f20185.m10140(protocol);
            try {
                Certificate[] peerCertificates = sSLSession.getPeerCertificates();
                listM10160 = peerCertificates != null ? C6943.m10160((Certificate[]) Arrays.copyOf(peerCertificates, peerCertificates.length)) : C6563.f19343;
            } catch (SSLPeerUnverifiedException unused) {
                listM10160 = C6563.f19343;
            }
            Certificate[] localCertificates = sSLSession.getLocalCertificates();
            return new C6901(enumC6939M10140, c6876M10034, localCertificates != null ? C6943.m10160((Certificate[]) Arrays.copyOf(localCertificates, localCertificates.length)) : C6563.f19343, new C6903(listM10160));
        }
    }

    /* JADX INFO: renamed from: ސ.ޒ$ؠ, reason: contains not printable characters */
    public static final class C6904 extends AbstractC6636 implements InterfaceC6603<List<? extends Certificate>> {

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public final /* synthetic */ InterfaceC6603 f20007;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C6904(InterfaceC6603 interfaceC6603) {
            super(0);
            this.f20007 = interfaceC6603;
        }

        @Override // p402.p411.p412.InterfaceC6603
        /* JADX INFO: renamed from: ނ */
        public List<? extends Certificate> mo1543() {
            try {
                return (List) this.f20007.mo1543();
            } catch (SSLPeerUnverifiedException unused) {
                return C6563.f19343;
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public C6901(EnumC6939 enumC6939, C6876 c6876, List<? extends Certificate> list, InterfaceC6603<? extends List<? extends Certificate>> interfaceC6603) {
        if (enumC6939 == null) {
            C6635.m9824("tlsVersion");
            throw null;
        }
        if (c6876 == null) {
            C6635.m9824("cipherSuite");
            throw null;
        }
        if (list == 0) {
            C6635.m9824("localCertificates");
            throw null;
        }
        if (interfaceC6603 == null) {
            C6635.m9824("peerCertificatesFn");
            throw null;
        }
        this.f20003 = enumC6939;
        this.f20004 = c6876;
        this.f20005 = list;
        this.f20002 = C4303.m7065((InterfaceC6603) new C6904(interfaceC6603));
    }

    public boolean equals(Object obj) {
        if (obj instanceof C6901) {
            C6901 c6901 = (C6901) obj;
            if (c6901.f20003 == this.f20003 && C6635.m9825(c6901.f20004, this.f20004) && C6635.m9825(c6901.m10065(), m10065()) && C6635.m9825(c6901.f20005, this.f20005)) {
                return true;
            }
        }
        return false;
    }

    public int hashCode() {
        return this.f20005.hashCode() + ((m10065().hashCode() + ((this.f20004.hashCode() + ((this.f20003.hashCode() + 527) * 31)) * 31)) * 31);
    }

    public String toString() {
        List<Certificate> listM10065 = m10065();
        ArrayList arrayList = new ArrayList(C4303.m6985(listM10065, 10));
        Iterator<T> it = listM10065.iterator();
        while (it.hasNext()) {
            arrayList.add(m10064((Certificate) it.next()));
        }
        String string = arrayList.toString();
        StringBuilder sbM4897 = C2803.m4897("Handshake{", "tlsVersion=");
        sbM4897.append(this.f20003);
        sbM4897.append(' ');
        sbM4897.append("cipherSuite=");
        sbM4897.append(this.f20004);
        sbM4897.append(' ');
        sbM4897.append("peerCertificates=");
        sbM4897.append(string);
        sbM4897.append(' ');
        sbM4897.append("localCertificates=");
        List<Certificate> list = this.f20005;
        ArrayList arrayList2 = new ArrayList(C4303.m6985(list, 10));
        Iterator<T> it2 = list.iterator();
        while (it2.hasNext()) {
            arrayList2.add(m10064((Certificate) it2.next()));
        }
        sbM4897.append(arrayList2);
        sbM4897.append('}');
        return sbM4897.toString();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final String m10064(Certificate certificate) {
        if (certificate instanceof X509Certificate) {
            return ((X509Certificate) certificate).getSubjectDN().toString();
        }
        String type = certificate.getType();
        C6635.m9823((Object) type, "type");
        return type;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final List<Certificate> m10065() {
        return (List) this.f20002.getValue();
    }
}
