- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
118 lines
4.3 KiB
Java
118 lines
4.3 KiB
Java
package okhttp3;
|
|
|
|
import com.amazonaws.handlers.HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0;
|
|
import com.facebook.internal.security.CertificateUtil;
|
|
import java.security.cert.Certificate;
|
|
import java.security.cert.X509Certificate;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import javax.net.ssl.SSLPeerUnverifiedException;
|
|
import okhttp3.internal.tls.CertificateChainCleaner;
|
|
import okio.ByteString;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public final class CertificatePinner {
|
|
public static final CertificatePinner DEFAULT = new Builder().build();
|
|
public final CertificateChainCleaner certificateChainCleaner;
|
|
public final Set pins;
|
|
|
|
public CertificatePinner(Set set, CertificateChainCleaner certificateChainCleaner) {
|
|
this.pins = set;
|
|
this.certificateChainCleaner = certificateChainCleaner;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
if (obj instanceof CertificatePinner) {
|
|
CertificatePinner certificatePinner = (CertificatePinner) obj;
|
|
if (Objects.equals(this.certificateChainCleaner, certificatePinner.certificateChainCleaner) && this.pins.equals(certificatePinner.pins)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return (Objects.hashCode(this.certificateChainCleaner) * 31) + this.pins.hashCode();
|
|
}
|
|
|
|
public void check(String str, List list) {
|
|
List findMatchingPins = findMatchingPins(str);
|
|
if (findMatchingPins.isEmpty()) {
|
|
return;
|
|
}
|
|
CertificateChainCleaner certificateChainCleaner = this.certificateChainCleaner;
|
|
if (certificateChainCleaner != null) {
|
|
list = certificateChainCleaner.clean(list, str);
|
|
}
|
|
int size = list.size();
|
|
for (int i = 0; i < size; i++) {
|
|
if (findMatchingPins.size() > 0) {
|
|
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(findMatchingPins.get(0));
|
|
throw null;
|
|
}
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Certificate pinning failure!");
|
|
sb.append("\n Peer certificate chain:");
|
|
int size2 = list.size();
|
|
for (int i2 = 0; i2 < size2; i2++) {
|
|
X509Certificate x509Certificate = (X509Certificate) list.get(i2);
|
|
sb.append("\n ");
|
|
sb.append(pin(x509Certificate));
|
|
sb.append(": ");
|
|
sb.append(x509Certificate.getSubjectDN().getName());
|
|
}
|
|
sb.append("\n Pinned certificates for ");
|
|
sb.append(str);
|
|
sb.append(CertificateUtil.DELIMITER);
|
|
int size3 = findMatchingPins.size();
|
|
for (int i3 = 0; i3 < size3; i3++) {
|
|
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(findMatchingPins.get(i3));
|
|
sb.append("\n ");
|
|
sb.append((Object) null);
|
|
}
|
|
throw new SSLPeerUnverifiedException(sb.toString());
|
|
}
|
|
|
|
public List findMatchingPins(String str) {
|
|
List emptyList = Collections.emptyList();
|
|
Iterator it = this.pins.iterator();
|
|
if (!it.hasNext()) {
|
|
return emptyList;
|
|
}
|
|
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(it.next());
|
|
throw null;
|
|
}
|
|
|
|
public CertificatePinner withCertificateChainCleaner(CertificateChainCleaner certificateChainCleaner) {
|
|
return Objects.equals(this.certificateChainCleaner, certificateChainCleaner) ? this : new CertificatePinner(this.pins, certificateChainCleaner);
|
|
}
|
|
|
|
public static String pin(Certificate certificate) {
|
|
if (!(certificate instanceof X509Certificate)) {
|
|
throw new IllegalArgumentException("Certificate pinning requires X509 certificates");
|
|
}
|
|
return "sha256/" + sha256((X509Certificate) certificate).base64();
|
|
}
|
|
|
|
public static ByteString sha256(X509Certificate x509Certificate) {
|
|
return ByteString.of(x509Certificate.getPublicKey().getEncoded()).sha256();
|
|
}
|
|
|
|
public static final class Builder {
|
|
public final List pins = new ArrayList();
|
|
|
|
public CertificatePinner build() {
|
|
return new CertificatePinner(new LinkedHashSet(this.pins), null);
|
|
}
|
|
}
|
|
}
|