135 lines
4.9 KiB
Java
135 lines
4.9 KiB
Java
|
package f0.f0.k;
|
||
|
|
||
|
import d0.t.o;
|
||
|
import d0.z.d.m;
|
||
|
import f0.y;
|
||
|
import java.security.KeyStore;
|
||
|
import java.security.Provider;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import javax.net.ssl.SSLContext;
|
||
|
import javax.net.ssl.SSLSocket;
|
||
|
import javax.net.ssl.TrustManager;
|
||
|
import javax.net.ssl.TrustManagerFactory;
|
||
|
import javax.net.ssl.X509TrustManager;
|
||
|
import kotlin.TypeCastException;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
import org.bouncycastle.jsse.BCSSLParameters;
|
||
|
import org.bouncycastle.jsse.BCSSLSocket;
|
||
|
import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
|
||
|
/* compiled from: BouncyCastlePlatform.kt */
|
||
|
public final class c extends h {
|
||
|
public static final boolean d;
|
||
|
public static final a e;
|
||
|
public final Provider f = new BouncyCastleJsseProvider();
|
||
|
|
||
|
/* compiled from: BouncyCastlePlatform.kt */
|
||
|
public static final class a {
|
||
|
public a(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static {
|
||
|
a aVar = new a(null);
|
||
|
e = aVar;
|
||
|
boolean z2 = false;
|
||
|
try {
|
||
|
Class.forName("org.bouncycastle.jsse.provider.BouncyCastleJsseProvider", false, aVar.getClass().getClassLoader());
|
||
|
z2 = true;
|
||
|
} catch (ClassNotFoundException unused) {
|
||
|
}
|
||
|
d = z2;
|
||
|
}
|
||
|
|
||
|
@Override // f0.f0.k.h
|
||
|
public void d(SSLSocket sSLSocket, String str, List<y> list) {
|
||
|
m.checkParameterIsNotNull(sSLSocket, "sslSocket");
|
||
|
m.checkParameterIsNotNull(list, "protocols");
|
||
|
if (sSLSocket instanceof BCSSLSocket) {
|
||
|
BCSSLSocket bCSSLSocket = (BCSSLSocket) sSLSocket;
|
||
|
BCSSLParameters parameters = bCSSLSocket.getParameters();
|
||
|
m.checkParameterIsNotNull(list, "protocols");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
Iterator<T> it = list.iterator();
|
||
|
while (true) {
|
||
|
boolean z2 = false;
|
||
|
if (!it.hasNext()) {
|
||
|
break;
|
||
|
}
|
||
|
Object next = it.next();
|
||
|
if (((y) next) != y.HTTP_1_0) {
|
||
|
z2 = true;
|
||
|
}
|
||
|
if (z2) {
|
||
|
arrayList.add(next);
|
||
|
}
|
||
|
}
|
||
|
ArrayList arrayList2 = new ArrayList(o.collectionSizeOrDefault(arrayList, 10));
|
||
|
Iterator it2 = arrayList.iterator();
|
||
|
while (it2.hasNext()) {
|
||
|
arrayList2.add(((y) it2.next()).toString());
|
||
|
}
|
||
|
m.checkExpressionValueIsNotNull(parameters, "sslParameters");
|
||
|
Object[] array = arrayList2.toArray(new String[0]);
|
||
|
if (array != null) {
|
||
|
parameters.setApplicationProtocols((String[]) array);
|
||
|
bCSSLSocket.setParameters(parameters);
|
||
|
return;
|
||
|
}
|
||
|
throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
|
||
|
}
|
||
|
m.checkParameterIsNotNull(sSLSocket, "sslSocket");
|
||
|
m.checkParameterIsNotNull(list, "protocols");
|
||
|
}
|
||
|
|
||
|
@Override // f0.f0.k.h
|
||
|
public String f(SSLSocket sSLSocket) {
|
||
|
m.checkParameterIsNotNull(sSLSocket, "sslSocket");
|
||
|
if (sSLSocket instanceof BCSSLSocket) {
|
||
|
String applicationProtocol = ((BCSSLSocket) sSLSocket).getApplicationProtocol();
|
||
|
if (applicationProtocol != null && !m.areEqual(applicationProtocol, "")) {
|
||
|
return applicationProtocol;
|
||
|
}
|
||
|
} else {
|
||
|
super.f(sSLSocket);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override // f0.f0.k.h
|
||
|
public SSLContext l() {
|
||
|
SSLContext instance = SSLContext.getInstance("TLS", this.f);
|
||
|
m.checkExpressionValueIsNotNull(instance, "SSLContext.getInstance(\"TLS\", provider)");
|
||
|
return instance;
|
||
|
}
|
||
|
|
||
|
@Override // f0.f0.k.h
|
||
|
public X509TrustManager n() {
|
||
|
TrustManagerFactory instance = TrustManagerFactory.getInstance("PKIX", "BCJSSE");
|
||
|
instance.init((KeyStore) null);
|
||
|
m.checkExpressionValueIsNotNull(instance, "factory");
|
||
|
TrustManager[] trustManagers = instance.getTrustManagers();
|
||
|
if (trustManagers == null) {
|
||
|
m.throwNpe();
|
||
|
}
|
||
|
boolean z2 = true;
|
||
|
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
|
||
|
z2 = false;
|
||
|
}
|
||
|
if (z2) {
|
||
|
TrustManager trustManager = trustManagers[0];
|
||
|
if (trustManager != null) {
|
||
|
return (X509TrustManager) trustManager;
|
||
|
}
|
||
|
throw new TypeCastException("null cannot be cast to non-null type javax.net.ssl.X509TrustManager");
|
||
|
}
|
||
|
StringBuilder L = c.d.b.a.a.L("Unexpected default trust managers: ");
|
||
|
String arrays = Arrays.toString(trustManagers);
|
||
|
m.checkExpressionValueIsNotNull(arrays, "java.util.Arrays.toString(this)");
|
||
|
L.append(arrays);
|
||
|
throw new IllegalStateException(L.toString().toString());
|
||
|
}
|
||
|
}
|