package defpackage;

import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;

/* renamed from: ᵺʽ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C5098 implements HostnameVerifier {

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static final C5098 f19047 = new C5098();

    /* JADX WARN: Removed duplicated region for block: B:59:0x00e1  */
    /* renamed from: ˏᵙ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static boolean m10562(java.lang.String r9, java.security.cert.X509Certificate r10) throws java.security.cert.CertificateParsingException {
        /*
            Method dump skipped, instructions count: 272
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C5098.m10562(java.lang.String, java.security.cert.X509Certificate):boolean");
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static List m10563(X509Certificate x509Certificate, int i) throws CertificateParsingException {
        Collection<List<?>> subjectAlternativeNames;
        Object obj;
        try {
            subjectAlternativeNames = x509Certificate.getSubjectAlternativeNames();
        } catch (CertificateParsingException unused) {
        }
        if (subjectAlternativeNames == null) {
            return C3035.f11677;
        }
        ArrayList arrayList = new ArrayList();
        for (List<?> list : subjectAlternativeNames) {
            if (list != null && list.size() >= 2 && ᵲᵝᵪ.ᵹᵝᵶ(list.get(0), Integer.valueOf(i)) && (obj = list.get(1)) != null) {
                arrayList.add((String) obj);
            }
        }
        return arrayList;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static boolean m10564(String str) {
        long j;
        int length = str.length();
        int length2 = str.length();
        if (length2 < 0) {
            ᵹˉᵞ.ᵸˑ(AbstractC3915.m8596(length2, "endIndex < beginIndex: ", " < 0"));
            return false;
        }
        if (length2 > str.length()) {
            ᵹˉᵞ.ˎˏʜʾ(str.length(), AbstractC1327.m4097(length2, "endIndex > string.length: ", " > "));
            return false;
        }
        long j2 = 0;
        int i = 0;
        while (i < length2) {
            char cCharAt = str.charAt(i);
            if (cCharAt < 128) {
                j2++;
            } else {
                if (cCharAt < 2048) {
                    j = 2;
                } else if (cCharAt < 55296 || cCharAt > 57343) {
                    j = 3;
                } else {
                    int i2 = i + 1;
                    char cCharAt2 = i2 < length2 ? str.charAt(i2) : (char) 0;
                    if (cCharAt > 56319 || cCharAt2 < 56320 || cCharAt2 > 57343) {
                        j2++;
                        i = i2;
                    } else {
                        j2 += 4;
                        i += 2;
                    }
                }
                j2 += j;
            }
            i++;
        }
        return length == ((int) j2);
    }

    @Override // javax.net.ssl.HostnameVerifier
    public final boolean verify(String str, SSLSession sSLSession) {
        if (m10564(str)) {
            try {
                return m10562(str, (X509Certificate) sSLSession.getPeerCertificates()[0]);
            } catch (SSLException unused) {
            }
        }
        return false;
    }
}
