68 lines
2.3 KiB
Java
68 lines
2.3 KiB
Java
package okhttp3.internal.tls;
|
|
|
|
import java.security.cert.X509Certificate;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import javax.security.auth.x500.X500Principal;
|
|
import o.C14957gcv;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class BasicTrustRootIndex implements TrustRootIndex {
|
|
private final Map<X500Principal, Set<X509Certificate>> subjectToCaCerts;
|
|
|
|
public BasicTrustRootIndex(X509Certificate... x509CertificateArr) {
|
|
C14957gcv.e(x509CertificateArr, "");
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
int length = x509CertificateArr.length;
|
|
int i = 0;
|
|
while (i < length) {
|
|
X509Certificate x509Certificate = x509CertificateArr[i];
|
|
i++;
|
|
X500Principal subjectX500Principal = x509Certificate.getSubjectX500Principal();
|
|
C14957gcv.c(subjectX500Principal, "");
|
|
Object obj = linkedHashMap.get(subjectX500Principal);
|
|
if (obj == null) {
|
|
obj = (Set) new LinkedHashSet();
|
|
linkedHashMap.put(subjectX500Principal, obj);
|
|
}
|
|
((Set) obj).add(x509Certificate);
|
|
}
|
|
this.subjectToCaCerts = linkedHashMap;
|
|
}
|
|
|
|
@Override // okhttp3.internal.tls.TrustRootIndex
|
|
public final X509Certificate findByIssuerAndSignature(X509Certificate x509Certificate) {
|
|
C14957gcv.e(x509Certificate, "");
|
|
Set<X509Certificate> set = this.subjectToCaCerts.get(x509Certificate.getIssuerX500Principal());
|
|
Object obj = null;
|
|
if (set == null) {
|
|
return null;
|
|
}
|
|
Iterator<T> it = set.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
Object next = it.next();
|
|
try {
|
|
x509Certificate.verify(((X509Certificate) next).getPublicKey());
|
|
obj = next;
|
|
break;
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
return (X509Certificate) obj;
|
|
}
|
|
|
|
public final boolean equals(Object obj) {
|
|
return obj == this || ((obj instanceof BasicTrustRootIndex) && C14957gcv.b(((BasicTrustRootIndex) obj).subjectToCaCerts, this.subjectToCaCerts));
|
|
}
|
|
|
|
public final int hashCode() {
|
|
return this.subjectToCaCerts.hashCode();
|
|
}
|
|
}
|