package p447;

import java.security.Principal;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.net.ssl.SSLPeerUnverifiedException;
import kotlin.jvm.internal.DefaultConstructorMarker;
import p138.p139.p143.p144.C2803;
import p402.InterfaceC6540;
import p402.p403.C6560;
import p402.p403.C6563;
import p402.p411.p412.InterfaceC6603;
import p402.p411.p413.C6635;
import p402.p411.p413.C6649;
import p402.p411.p413.p414.InterfaceC6650;
import p402.p420.C6703;
import p447.p448.p460.AbstractC7093;
import p461.C7108;

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

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Set<C6873> f19928;

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

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public static final C6872 f19927 = new C6872(null);

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static final C6871 f19926 = new C6871(C6560.m9795((Iterable) new ArrayList()), 0 == true ? 1 : 0, 2, 0 == true ? 1 : 0);

    /* JADX INFO: renamed from: ސ.ބ$֏, reason: contains not printable characters */
    public static final class C6872 {
        public C6872() {
        }

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

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final String m10031(Certificate certificate) {
            if (certificate == null) {
                C6635.m9824("certificate");
                throw null;
            }
            if (!(certificate instanceof X509Certificate)) {
                throw new IllegalArgumentException("Certificate pinning requires X509 certificates".toString());
            }
            StringBuilder sbM4889 = C2803.m4889("sha256/");
            sbM4889.append(m10032((X509Certificate) certificate).mo10449());
            return sbM4889.toString();
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final C7108 m10032(X509Certificate x509Certificate) {
            if (x509Certificate == null) {
                C6635.m9824("$this$sha256Hash");
                throw null;
            }
            C7108.C7109 c7109 = C7108.f20634;
            PublicKey publicKey = x509Certificate.getPublicKey();
            C6635.m9823((Object) publicKey, "publicKey");
            byte[] encoded = publicKey.getEncoded();
            C6635.m9823((Object) encoded, "publicKey.encoded");
            return C7108.C7109.m10455(c7109, encoded, 0, 0, 3).mo10444("SHA-256");
        }
    }

    /* JADX INFO: renamed from: ސ.ބ$ؠ, reason: contains not printable characters */
    public static final class C6873 {

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

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

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

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof C6873)) {
                return false;
            }
            C6873 c6873 = (C6873) obj;
            return ((C6635.m9825((Object) null, (Object) c6873.f19930) ^ true) || (C6635.m9825((Object) null, (Object) c6873.f19931) ^ true) || (C6635.m9825((Object) null, c6873.f19932) ^ true)) ? false : true;
        }

        public int hashCode() {
            throw null;
        }

        public String toString() {
            StringBuilder sb = new StringBuilder();
            sb.append((String) null);
            sb.append('/');
            throw null;
        }
    }

    public C6871(Set<C6873> set, AbstractC7093 abstractC7093) {
        if (set == null) {
            C6635.m9824("pins");
            throw null;
        }
        this.f19928 = set;
        this.f19929 = abstractC7093;
    }

    public /* synthetic */ C6871(Set set, AbstractC7093 abstractC7093, int i, DefaultConstructorMarker defaultConstructorMarker) {
        abstractC7093 = (i & 2) != 0 ? null : abstractC7093;
        if (set == null) {
            C6635.m9824("pins");
            throw null;
        }
        this.f19928 = set;
        this.f19929 = abstractC7093;
    }

    public boolean equals(Object obj) {
        if (obj instanceof C6871) {
            C6871 c6871 = (C6871) obj;
            if (C6635.m9825(c6871.f19928, this.f19928) && C6635.m9825(c6871.f19929, this.f19929)) {
                return true;
            }
        }
        return false;
    }

    public int hashCode() {
        int iHashCode = (this.f19928.hashCode() + 1517) * 41;
        AbstractC7093 abstractC7093 = this.f19929;
        return iHashCode + (abstractC7093 != null ? abstractC7093.hashCode() : 0);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C6871 m10029(AbstractC7093 abstractC7093) {
        if (abstractC7093 != null) {
            return C6635.m9825(this.f19929, abstractC7093) ? this : new C6871(this.f19928, abstractC7093);
        }
        C6635.m9824("certificateChainCleaner");
        throw null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m10030(String str, InterfaceC6603<? extends List<? extends X509Certificate>> interfaceC6603) throws SSLPeerUnverifiedException {
        if (str == null) {
            C6635.m9824("hostname");
            throw null;
        }
        if (interfaceC6603 == null) {
            C6635.m9824("cleanedPeerCertificatesFn");
            throw null;
        }
        Set<C6873> set = this.f19928;
        List<C6873> arrayList = C6563.f19343;
        for (Object obj : set) {
            if (((C6873) obj) == null) {
                throw null;
            }
            if (C6703.m9899((String) null, "**.", false, 2)) {
                throw null;
            }
            if (C6703.m9899((String) null, "*.", false, 2)) {
                throw null;
            }
            if (C6635.m9825(str, (Object) null)) {
                if (arrayList.isEmpty()) {
                    arrayList = new ArrayList();
                }
                if (arrayList instanceof InterfaceC6650) {
                    C6649.m9834(arrayList, "kotlin.collections.MutableList");
                    throw null;
                }
                arrayList.add(obj);
            }
        }
        if (arrayList.isEmpty()) {
            return;
        }
        List<? extends X509Certificate> listMo1543 = interfaceC6603.mo1543();
        for (X509Certificate x509Certificate : listMo1543) {
            Iterator it = arrayList.iterator();
            if (it.hasNext()) {
                if (((C6873) it.next()) == null) {
                    throw null;
                }
                throw null;
            }
        }
        StringBuilder sbM4897 = C2803.m4897("Certificate pinning failure!", "\n  Peer certificate chain:");
        for (X509Certificate x509Certificate2 : listMo1543) {
            sbM4897.append("\n    ");
            sbM4897.append(f19927.m10031((Certificate) x509Certificate2));
            sbM4897.append(": ");
            Principal subjectDN = x509Certificate2.getSubjectDN();
            C6635.m9823((Object) subjectDN, "element.subjectDN");
            sbM4897.append(subjectDN.getName());
        }
        sbM4897.append("\n  Pinned certificates for ");
        sbM4897.append(str);
        sbM4897.append(":");
        for (C6873 c6873 : arrayList) {
            sbM4897.append("\n    ");
            sbM4897.append(c6873);
        }
        String string = sbM4897.toString();
        C6635.m9823((Object) string, "StringBuilder().apply(builderAction).toString()");
        throw new SSLPeerUnverifiedException(string);
    }
}
