what-the-bank/sources/okhttp3/repackaged/internal/tls/AndroidTrustRootIndex.java

44 lines
1.6 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3.repackaged.internal.tls;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.cert.TrustAnchor;
import java.security.cert.X509Certificate;
import javax.net.ssl.X509TrustManager;
/* loaded from: classes6.dex */
public final class AndroidTrustRootIndex implements TrustRootIndex {
private final X509TrustManager amQ;
private final Method amR;
public AndroidTrustRootIndex(X509TrustManager x509TrustManager, Method method) {
this.amR = method;
this.amQ = x509TrustManager;
}
@Override // okhttp3.repackaged.internal.tls.TrustRootIndex
public final X509Certificate findByIssuerAndSignature(X509Certificate x509Certificate) {
try {
TrustAnchor trustAnchor = (TrustAnchor) this.amR.invoke(this.amQ, x509Certificate);
if (trustAnchor != null) {
return trustAnchor.getTrustedCert();
}
return null;
} catch (IllegalAccessException unused) {
throw new AssertionError();
} catch (InvocationTargetException unused2) {
return null;
}
}
public static TrustRootIndex get(X509TrustManager x509TrustManager) {
try {
Method declaredMethod = x509TrustManager.getClass().getDeclaredMethod("findTrustAnchorByIssuerAndSignature", X509Certificate.class);
declaredMethod.setAccessible(true);
return new AndroidTrustRootIndex(x509TrustManager, declaredMethod);
} catch (NoSuchMethodException unused) {
return null;
}
}
}