78 lines
2.6 KiB
Java
78 lines
2.6 KiB
Java
|
package com.facetec.sdk;
|
||
|
|
||
|
import java.security.GeneralSecurityException;
|
||
|
import java.security.cert.Certificate;
|
||
|
import java.security.cert.X509Certificate;
|
||
|
import java.util.ArrayDeque;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import javax.net.ssl.SSLPeerUnverifiedException;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class ml extends mm {
|
||
|
private final mq b;
|
||
|
|
||
|
public ml(mq mqVar) {
|
||
|
this.b = mqVar;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mm
|
||
|
public final List<Certificate> a(List<Certificate> list, String str) throws SSLPeerUnverifiedException {
|
||
|
ArrayDeque arrayDeque = new ArrayDeque(list);
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
arrayList.add(arrayDeque.removeFirst());
|
||
|
boolean z = false;
|
||
|
for (int i = 0; i < 9; i++) {
|
||
|
X509Certificate x509Certificate = (X509Certificate) arrayList.get(arrayList.size() - 1);
|
||
|
X509Certificate a = this.b.a(x509Certificate);
|
||
|
if (a != null) {
|
||
|
if (arrayList.size() > 1 || !x509Certificate.equals(a)) {
|
||
|
arrayList.add(a);
|
||
|
}
|
||
|
if (d(a, a)) {
|
||
|
return arrayList;
|
||
|
}
|
||
|
z = true;
|
||
|
} else {
|
||
|
Iterator it = arrayDeque.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
X509Certificate x509Certificate2 = (X509Certificate) it.next();
|
||
|
if (d(x509Certificate, x509Certificate2)) {
|
||
|
it.remove();
|
||
|
arrayList.add(x509Certificate2);
|
||
|
}
|
||
|
}
|
||
|
if (z) {
|
||
|
return arrayList;
|
||
|
}
|
||
|
throw new SSLPeerUnverifiedException("Failed to find a trusted cert that signed ".concat(String.valueOf(x509Certificate)));
|
||
|
}
|
||
|
}
|
||
|
throw new SSLPeerUnverifiedException("Certificate chain too long: ".concat(String.valueOf(arrayList)));
|
||
|
}
|
||
|
|
||
|
private static boolean d(X509Certificate x509Certificate, X509Certificate x509Certificate2) {
|
||
|
if (!x509Certificate.getIssuerDN().equals(x509Certificate2.getSubjectDN())) {
|
||
|
return false;
|
||
|
}
|
||
|
try {
|
||
|
x509Certificate.verify(x509Certificate2.getPublicKey());
|
||
|
return true;
|
||
|
} catch (GeneralSecurityException unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final int hashCode() {
|
||
|
return this.b.hashCode();
|
||
|
}
|
||
|
|
||
|
public final boolean equals(Object obj) {
|
||
|
if (obj == this) {
|
||
|
return true;
|
||
|
}
|
||
|
return (obj instanceof ml) && ((ml) obj).b.equals(this.b);
|
||
|
}
|
||
|
}
|