package 㿎.ሽ.㳳;

import com.facebook.appevents.codeless.CodelessMatcher;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import 㿎.ሽ.C2540;

/* renamed from: 㿎.ሽ.㳳.㸾  reason: contains not printable characters */
/* compiled from: OkHostnameVerifier */
public final class C2575 implements HostnameVerifier {

    /* renamed from: K  reason: contains not printable characters */
    public static final C2575 f8679 = new C2575();

    /* renamed from: K  reason: contains not printable characters */
    public static List<String> m6771(X509Certificate x509Certificate) {
        List<String> r0 = m6772(x509Certificate, 7);
        List<String> r4 = m6772(x509Certificate, 2);
        ArrayList arrayList = new ArrayList(r4.size() + r0.size());
        arrayList.addAll(r0);
        arrayList.addAll(r4);
        return arrayList;
    }

    public boolean verify(String str, SSLSession sSLSession) {
        try {
            return m6773(str, (X509Certificate) sSLSession.getPeerCertificates()[0]);
        } catch (SSLException unused) {
            return false;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static List<String> m6772(X509Certificate x509Certificate, int i) {
        String str;
        ArrayList arrayList = new ArrayList();
        try {
            Collection<List<?>> subjectAlternativeNames = x509Certificate.getSubjectAlternativeNames();
            if (subjectAlternativeNames == null) {
                return Collections.emptyList();
            }
            for (List<?> list : subjectAlternativeNames) {
                if (list != null) {
                    if (list.size() >= 2) {
                        Integer num = (Integer) list.get(0);
                        if (num != null) {
                            if (num.intValue() == i && (str = (String) list.get(1)) != null) {
                                arrayList.add(str);
                            }
                        }
                    }
                }
            }
            return arrayList;
        } catch (CertificateParsingException unused) {
            return Collections.emptyList();
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:55:0x00ff A[SYNTHETIC] */
    /* renamed from: K  reason: contains not printable characters */
    public boolean m6773(String str, X509Certificate x509Certificate) {
        boolean z;
        int length;
        if (C2540.f8564.matcher(str).matches()) {
            List<String> r11 = m6772(x509Certificate, 7);
            int size = r11.size();
            for (int i = 0; i < size; i++) {
                if (!str.equalsIgnoreCase(r11.get(i))) {
                }
            }
            return false;
        }
        String lowerCase = str.toLowerCase(Locale.US);
        for (String str2 : m6772(x509Certificate, 2)) {
            if (lowerCase != null && lowerCase.length() != 0 && !lowerCase.startsWith(CodelessMatcher.CURRENT_CLASS_NAME) && !lowerCase.endsWith("..") && str2 != null && str2.length() != 0 && !str2.startsWith(CodelessMatcher.CURRENT_CLASS_NAME) && !str2.endsWith("..")) {
                String str3 = !lowerCase.endsWith(CodelessMatcher.CURRENT_CLASS_NAME) ? lowerCase + '.' : lowerCase;
                if (!str2.endsWith(CodelessMatcher.CURRENT_CLASS_NAME)) {
                    str2 = str2 + '.';
                }
                String lowerCase2 = str2.toLowerCase(Locale.US);
                if (!lowerCase2.contains("*")) {
                    z = str3.equals(lowerCase2);
                    continue;
                } else if (lowerCase2.startsWith("*.") && lowerCase2.indexOf(42, 1) == -1 && str3.length() >= lowerCase2.length() && !"*.".equals(lowerCase2)) {
                    String substring = lowerCase2.substring(1);
                    if (str3.endsWith(substring) && ((length = str3.length() - substring.length()) <= 0 || str3.lastIndexOf(46, length - 1) == -1)) {
                        z = true;
                        continue;
                    }
                }
                if (z) {
                }
            }
            z = false;
            continue;
            if (z) {
            }
        }
        return false;
        return true;
    }
}
