HttpsUtils.smali
.class public Lcom/zhy/http/okhttp/https/HttpsUtils;
.super Ljava/lang/Object;
.source "HttpsUtils.java"
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/zhy/http/okhttp/https/HttpsUtils$MyTrustManager;,
Lcom/zhy/http/okhttp/https/HttpsUtils$UnSafeTrustManager;,
Lcom/zhy/http/okhttp/https/HttpsUtils$UnSafeHostnameVerifier;,
Lcom/zhy/http/okhttp/https/HttpsUtils$SSLParams;
}
.end annotation
# direct methods
.method public constructor <init>()V
.registers 1
.line 27
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method static synthetic access$100([Ljavax/net/ssl/TrustManager;)Ljavax/net/ssl/X509TrustManager;
.registers 1
.line 27
invoke-static {p0}, Lcom/zhy/http/okhttp/https/HttpsUtils;->chooseTrustManager([Ljavax/net/ssl/TrustManager;)Ljavax/net/ssl/X509TrustManager;
move-result-object p0
return-object p0
.end method
.method private static chooseTrustManager([Ljavax/net/ssl/TrustManager;)Ljavax/net/ssl/X509TrustManager;
.registers 5
.line 182
array-length v0, p0
const/4 v1, 0x0
:goto_2
if-ge v1, v0, :cond_10
aget-object v2, p0, v1
.line 184
instance-of v3, v2, Ljavax/net/ssl/X509TrustManager;
if-eqz v3, :cond_d
.line 186
check-cast v2, Ljavax/net/ssl/X509TrustManager;
return-object v2
:cond_d
add-int/lit8 v1, v1, 0x1
goto :goto_2
:cond_10
const/4 p0, 0x0
return-object p0
.end method
.method public static getSslSocketFactory([Ljava/io/InputStream;Ljava/io/InputStream;Ljava/lang/String;)Lcom/zhy/http/okhttp/https/HttpsUtils$SSLParams;
.registers 7
.line 37
new-instance v0, Lcom/zhy/http/okhttp/https/HttpsUtils$SSLParams;
invoke-direct {v0}, Lcom/zhy/http/okhttp/https/HttpsUtils$SSLParams;-><init>()V
.line 40
:try_start_5
invoke-static {p0}, Lcom/zhy/http/okhttp/https/HttpsUtils;->prepareTrustManager([Ljava/io/InputStream;)[Ljavax/net/ssl/TrustManager;
move-result-object p0
.line 41
invoke-static {p1, p2}, Lcom/zhy/http/okhttp/https/HttpsUtils;->prepareKeyManager(Ljava/io/InputStream;Ljava/lang/String;)[Ljavax/net/ssl/KeyManager;
move-result-object p1
const-string p2, "TLS"
.line 42
invoke-static {p2}, Ljavax/net/ssl/SSLContext;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/SSLContext;
move-result-object p2
const/4 v1, 0x0
if-eqz p0, :cond_20
.line 46
new-instance v2, Lcom/zhy/http/okhttp/https/HttpsUtils$MyTrustManager;
invoke-static {p0}, Lcom/zhy/http/okhttp/https/HttpsUtils;->chooseTrustManager([Ljavax/net/ssl/TrustManager;)Ljavax/net/ssl/X509TrustManager;
move-result-object p0
invoke-direct {v2, p0}, Lcom/zhy/http/okhttp/https/HttpsUtils$MyTrustManager;-><init>(Ljavax/net/ssl/X509TrustManager;)V
goto :goto_25
.line 49
:cond_20
new-instance v2, Lcom/zhy/http/okhttp/https/HttpsUtils$UnSafeTrustManager;
invoke-direct {v2, v1}, Lcom/zhy/http/okhttp/https/HttpsUtils$UnSafeTrustManager;-><init>(Lcom/zhy/http/okhttp/https/HttpsUtils$1;)V
:goto_25
const/4 p0, 0x1
new-array p0, p0, [Ljavax/net/ssl/TrustManager;
const/4 v3, 0x0
aput-object v2, p0, v3
.line 51
invoke-virtual {p2, p1, p0, v1}, Ljavax/net/ssl/SSLContext;->init([Ljavax/net/ssl/KeyManager;[Ljavax/net/ssl/TrustManager;Ljava/security/SecureRandom;)V
.line 52
invoke-virtual {p2}, Ljavax/net/ssl/SSLContext;->getSocketFactory()Ljavax/net/ssl/SSLSocketFactory;
move-result-object p0
iput-object p0, v0, Lcom/zhy/http/okhttp/https/HttpsUtils$SSLParams;->sSLSocketFactory:Ljavax/net/ssl/SSLSocketFactory;
.line 53
iput-object v2, v0, Lcom/zhy/http/okhttp/https/HttpsUtils$SSLParams;->trustManager:Ljavax/net/ssl/X509TrustManager;
:try_end_36
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_5 .. :try_end_36} :catch_45
.catch Ljava/security/KeyManagementException; {:try_start_5 .. :try_end_36} :catch_3e
.catch Ljava/security/KeyStoreException; {:try_start_5 .. :try_end_36} :catch_37
return-object v0
:catch_37
move-exception p0
.line 63
new-instance p1, Ljava/lang/AssertionError;
invoke-direct {p1, p0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
throw p1
:catch_3e
move-exception p0
.line 60
new-instance p1, Ljava/lang/AssertionError;
invoke-direct {p1, p0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
throw p1
:catch_45
move-exception p0
.line 57
new-instance p1, Ljava/lang/AssertionError;
invoke-direct {p1, p0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
throw p1
.end method
.method private static prepareKeyManager(Ljava/io/InputStream;Ljava/lang/String;)[Ljavax/net/ssl/KeyManager;
.registers 5
const/4 v0, 0x0
if-eqz p0, :cond_44
if-nez p1, :cond_6
goto :goto_44
:cond_6
:try_start_6
const-string v1, "BKS"
.line 152
invoke-static {v1}, Ljava/security/KeyStore;->getInstance(Ljava/lang/String;)Ljava/security/KeyStore;
move-result-object v1
.line 153
invoke-virtual {p1}, Ljava/lang/String;->toCharArray()[C
move-result-object v2
invoke-virtual {v1, p0, v2}, Ljava/security/KeyStore;->load(Ljava/io/InputStream;[C)V
.line 154
invoke-static {}, Ljavax/net/ssl/KeyManagerFactory;->getDefaultAlgorithm()Ljava/lang/String;
move-result-object p0
invoke-static {p0}, Ljavax/net/ssl/KeyManagerFactory;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/KeyManagerFactory;
move-result-object p0
.line 155
invoke-virtual {p1}, Ljava/lang/String;->toCharArray()[C
move-result-object p1
invoke-virtual {p0, v1, p1}, Ljavax/net/ssl/KeyManagerFactory;->init(Ljava/security/KeyStore;[C)V
.line 156
invoke-virtual {p0}, Ljavax/net/ssl/KeyManagerFactory;->getKeyManagers()[Ljavax/net/ssl/KeyManager;
move-result-object p0
:try_end_26
.catch Ljava/security/KeyStoreException; {:try_start_6 .. :try_end_26} :catch_40
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_6 .. :try_end_26} :catch_3b
.catch Ljava/security/UnrecoverableKeyException; {:try_start_6 .. :try_end_26} :catch_36
.catch Ljava/security/cert/CertificateException; {:try_start_6 .. :try_end_26} :catch_31
.catch Ljava/io/IOException; {:try_start_6 .. :try_end_26} :catch_2c
.catch Ljava/lang/Exception; {:try_start_6 .. :try_end_26} :catch_27
return-object p0
:catch_27
move-exception p0
.line 175
invoke-virtual {p0}, Ljava/lang/Exception;->printStackTrace()V
goto :goto_44
:catch_2c
move-exception p0
.line 172
invoke-virtual {p0}, Ljava/io/IOException;->printStackTrace()V
goto :goto_44
:catch_31
move-exception p0
.line 169
invoke-virtual {p0}, Ljava/security/cert/CertificateException;->printStackTrace()V
goto :goto_44
:catch_36
move-exception p0
.line 166
invoke-virtual {p0}, Ljava/security/UnrecoverableKeyException;->printStackTrace()V
goto :goto_44
:catch_3b
move-exception p0
.line 163
invoke-virtual {p0}, Ljava/security/NoSuchAlgorithmException;->printStackTrace()V
goto :goto_44
:catch_40
move-exception p0
.line 160
invoke-virtual {p0}, Ljava/security/KeyStoreException;->printStackTrace()V
:cond_44
:goto_44
return-object v0
.end method
.method private static varargs prepareTrustManager([Ljava/io/InputStream;)[Ljavax/net/ssl/TrustManager;
.registers 10
const/4 v0, 0x0
if-eqz p0, :cond_58
.line 99
array-length v1, p0
if-gtz v1, :cond_7
goto :goto_58
:cond_7
:try_start_7
const-string v1, "X.509"
.line 103
invoke-static {v1}, Ljava/security/cert/CertificateFactory;->getInstance(Ljava/lang/String;)Ljava/security/cert/CertificateFactory;
move-result-object v1
.line 104
invoke-static {}, Ljava/security/KeyStore;->getDefaultType()Ljava/lang/String;
move-result-object v2
invoke-static {v2}, Ljava/security/KeyStore;->getInstance(Ljava/lang/String;)Ljava/security/KeyStore;
move-result-object v2
.line 105
invoke-virtual {v2, v0}, Ljava/security/KeyStore;->load(Ljava/security/KeyStore$LoadStoreParameter;)V
.line 107
array-length v3, p0
const/4 v4, 0x0
const/4 v5, 0x0
:goto_1b
if-ge v4, v3, :cond_35
aget-object v6, p0, v4
add-int/lit8 v7, v5, 0x1
.line 109
invoke-static {v5}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;
move-result-object v5
.line 110
invoke-virtual {v1, v6}, Ljava/security/cert/CertificateFactory;->generateCertificate(Ljava/io/InputStream;)Ljava/security/cert/Certificate;
move-result-object v8
invoke-virtual {v2, v5, v8}, Ljava/security/KeyStore;->setCertificateEntry(Ljava/lang/String;Ljava/security/cert/Certificate;)V
:try_end_2c
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_7 .. :try_end_2c} :catch_54
.catch Ljava/security/cert/CertificateException; {:try_start_7 .. :try_end_2c} :catch_4f
.catch Ljava/security/KeyStoreException; {:try_start_7 .. :try_end_2c} :catch_4a
.catch Ljava/lang/Exception; {:try_start_7 .. :try_end_2c} :catch_45
if-eqz v6, :cond_31
.line 114
:try_start_2e
invoke-virtual {v6}, Ljava/io/InputStream;->close()V
:try_end_31
.catch Ljava/io/IOException; {:try_start_2e .. :try_end_31} :catch_31
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_2e .. :try_end_31} :catch_54
.catch Ljava/security/cert/CertificateException; {:try_start_2e .. :try_end_31} :catch_4f
.catch Ljava/security/KeyStoreException; {:try_start_2e .. :try_end_31} :catch_4a
.catch Ljava/lang/Exception; {:try_start_2e .. :try_end_31} :catch_45
:catch_31
:cond_31
add-int/lit8 v4, v4, 0x1
move v5, v7
goto :goto_1b
.line 122
:cond_35
:try_start_35
invoke-static {}, Ljavax/net/ssl/TrustManagerFactory;->getDefaultAlgorithm()Ljava/lang/String;
move-result-object p0
invoke-static {p0}, Ljavax/net/ssl/TrustManagerFactory;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/TrustManagerFactory;
move-result-object p0
.line 124
invoke-virtual {p0, v2}, Ljavax/net/ssl/TrustManagerFactory;->init(Ljava/security/KeyStore;)V
.line 126
invoke-virtual {p0}, Ljavax/net/ssl/TrustManagerFactory;->getTrustManagers()[Ljavax/net/ssl/TrustManager;
move-result-object p0
:try_end_44
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_35 .. :try_end_44} :catch_54
.catch Ljava/security/cert/CertificateException; {:try_start_35 .. :try_end_44} :catch_4f
.catch Ljava/security/KeyStoreException; {:try_start_35 .. :try_end_44} :catch_4a
.catch Ljava/lang/Exception; {:try_start_35 .. :try_end_44} :catch_45
return-object p0
:catch_45
move-exception p0
.line 140
invoke-virtual {p0}, Ljava/lang/Exception;->printStackTrace()V
goto :goto_58
:catch_4a
move-exception p0
.line 137
invoke-virtual {p0}, Ljava/security/KeyStoreException;->printStackTrace()V
goto :goto_58
:catch_4f
move-exception p0
.line 134
invoke-virtual {p0}, Ljava/security/cert/CertificateException;->printStackTrace()V
goto :goto_58
:catch_54
move-exception p0
.line 131
invoke-virtual {p0}, Ljava/security/NoSuchAlgorithmException;->printStackTrace()V
:cond_58
:goto_58
return-object v0
.end method