2019-07-24 11:27:29 +00:00
|
|
|
.class public final Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;
|
|
|
|
.super Ljava/lang/Object;
|
|
|
|
.source "SecureSocketsLayerUtils.kt"
|
|
|
|
|
|
|
|
|
|
|
|
# static fields
|
|
|
|
.field public static final INSTANCE:Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;
|
|
|
|
|
|
|
|
|
|
|
|
# direct methods
|
2019-12-06 03:29:40 +00:00
|
|
|
.method public static constructor <clinit>()V
|
2019-07-24 11:27:29 +00:00
|
|
|
.locals 1
|
|
|
|
|
|
|
|
new-instance v0, Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;
|
|
|
|
|
|
|
|
invoke-direct {v0}, Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;-><init>()V
|
|
|
|
|
|
|
|
sput-object v0, Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;->INSTANCE:Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;
|
|
|
|
|
|
|
|
return-void
|
|
|
|
.end method
|
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
.method public constructor <init>()V
|
2019-07-24 11:27:29 +00:00
|
|
|
.locals 0
|
|
|
|
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
|
|
|
|
return-void
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public static final createSocketFactory()Ljavax/net/ssl/SSLSocketFactory;
|
|
|
|
.locals 2
|
|
|
|
|
|
|
|
const/4 v0, 0x0
|
|
|
|
|
|
|
|
const/4 v1, 0x1
|
|
|
|
|
|
|
|
invoke-static {v0, v1, v0}, Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;->createSocketFactory$default(Ljavax/net/ssl/TrustManagerFactory;ILjava/lang/Object;)Ljavax/net/ssl/SSLSocketFactory;
|
|
|
|
|
|
|
|
move-result-object v0
|
|
|
|
|
|
|
|
return-object v0
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public static final createSocketFactory(Ljavax/net/ssl/TrustManagerFactory;)Ljavax/net/ssl/SSLSocketFactory;
|
|
|
|
.locals 3
|
|
|
|
|
|
|
|
sget-object v0, Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;->INSTANCE:Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;
|
|
|
|
|
|
|
|
const/4 v1, 0x0
|
|
|
|
|
|
|
|
const/4 v2, 0x1
|
|
|
|
|
|
|
|
invoke-static {v0, v1, v2, v1}, Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;->getContext$default(Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;Ljava/lang/String;ILjava/lang/Object;)Ljavax/net/ssl/SSLContext;
|
|
|
|
|
|
|
|
move-result-object v0
|
|
|
|
|
|
|
|
if-eqz p0, :cond_0
|
|
|
|
|
|
|
|
:try_start_0
|
|
|
|
invoke-virtual {p0}, Ljavax/net/ssl/TrustManagerFactory;->getTrustManagers()[Ljavax/net/ssl/TrustManager;
|
|
|
|
|
|
|
|
move-result-object p0
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:catch_0
|
|
|
|
move-exception p0
|
|
|
|
|
|
|
|
goto :goto_1
|
|
|
|
|
|
|
|
:cond_0
|
|
|
|
move-object p0, v1
|
|
|
|
|
|
|
|
:goto_0
|
|
|
|
invoke-virtual {v0, v1, p0, v1}, Ljavax/net/ssl/SSLContext;->init([Ljavax/net/ssl/KeyManager;[Ljavax/net/ssl/TrustManager;Ljava/security/SecureRandom;)V
|
|
|
|
:try_end_0
|
|
|
|
.catch Ljava/security/KeyManagementException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljavax/net/ssl/SSLContext;->getSocketFactory()Ljavax/net/ssl/SSLSocketFactory;
|
|
|
|
|
|
|
|
move-result-object p0
|
|
|
|
|
|
|
|
const-string v0, "sslContext.socketFactory"
|
|
|
|
|
2019-12-18 07:41:41 +00:00
|
|
|
invoke-static {p0, v0}, Lm/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
|
|
|
|
return-object p0
|
|
|
|
|
|
|
|
:goto_1
|
|
|
|
throw p0
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public static synthetic createSocketFactory$default(Ljavax/net/ssl/TrustManagerFactory;ILjava/lang/Object;)Ljavax/net/ssl/SSLSocketFactory;
|
|
|
|
.locals 0
|
|
|
|
|
|
|
|
and-int/lit8 p1, p1, 0x1
|
|
|
|
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
|
|
|
|
const/4 p0, 0x0
|
|
|
|
|
|
|
|
:cond_0
|
|
|
|
invoke-static {p0}, Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;->createSocketFactory(Ljavax/net/ssl/TrustManagerFactory;)Ljavax/net/ssl/SSLSocketFactory;
|
|
|
|
|
|
|
|
move-result-object p0
|
|
|
|
|
|
|
|
return-object p0
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method private final getContext(Ljava/lang/String;)Ljavax/net/ssl/SSLContext;
|
|
|
|
.locals 1
|
|
|
|
|
|
|
|
:try_start_0
|
|
|
|
invoke-static {p1}, Ljavax/net/ssl/SSLContext;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/SSLContext;
|
|
|
|
|
|
|
|
move-result-object p1
|
|
|
|
|
|
|
|
const-string v0, "SSLContext.getInstance(protocol)"
|
|
|
|
|
2019-12-18 07:41:41 +00:00
|
|
|
invoke-static {p1, v0}, Lm/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
:try_end_0
|
|
|
|
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
|
|
|
|
return-object p1
|
|
|
|
|
|
|
|
:catch_0
|
|
|
|
move-exception p1
|
|
|
|
|
|
|
|
throw p1
|
|
|
|
.end method
|
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
.method public static synthetic getContext$default(Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;Ljava/lang/String;ILjava/lang/Object;)Ljavax/net/ssl/SSLContext;
|
2019-07-24 11:27:29 +00:00
|
|
|
.locals 0
|
|
|
|
|
|
|
|
and-int/lit8 p2, p2, 0x1
|
|
|
|
|
|
|
|
if-eqz p2, :cond_0
|
|
|
|
|
|
|
|
const-string p1, "TLS"
|
|
|
|
|
|
|
|
:cond_0
|
|
|
|
invoke-direct {p0, p1}, Lcom/discord/utilities/ssl/SecureSocketsLayerUtils;->getContext(Ljava/lang/String;)Ljavax/net/ssl/SSLContext;
|
|
|
|
|
|
|
|
move-result-object p0
|
|
|
|
|
|
|
|
return-object p0
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public static final getTrustManagerFactory(Landroid/content/res/AssetManager;Ljava/lang/String;)Ljavax/net/ssl/TrustManagerFactory;
|
|
|
|
.locals 4
|
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
const/4 v0, 0x0
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
if-eqz p0, :cond_2
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
if-eqz p1, :cond_1
|
2019-07-24 11:27:29 +00:00
|
|
|
|
|
|
|
invoke-static {}, Ljavax/net/ssl/TrustManagerFactory;->getDefaultAlgorithm()Ljava/lang/String;
|
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
move-result-object v1
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-static {v1}, Ljavax/net/ssl/TrustManagerFactory;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/TrustManagerFactory;
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
move-result-object v1
|
2019-07-24 11:27:29 +00:00
|
|
|
|
|
|
|
invoke-virtual {p0, p1}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;
|
|
|
|
|
|
|
|
move-result-object p0
|
|
|
|
|
|
|
|
:try_start_0
|
2019-12-06 03:29:40 +00:00
|
|
|
const-string p1, "X.509"
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-static {p1}, Ljava/security/cert/CertificateFactory;->getInstance(Ljava/lang/String;)Ljava/security/cert/CertificateFactory;
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
move-result-object p1
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-virtual {p1, p0}, Ljava/security/cert/CertificateFactory;->generateCertificate(Ljava/io/InputStream;)Ljava/security/cert/Certificate;
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-08-30 20:04:20 +00:00
|
|
|
move-result-object p1
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-08-30 20:04:20 +00:00
|
|
|
if-eqz p1, :cond_0
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-08-30 20:04:20 +00:00
|
|
|
check-cast p1, Ljava/security/cert/X509Certificate;
|
2019-07-24 11:27:29 +00:00
|
|
|
|
|
|
|
invoke-static {}, Ljava/security/KeyStore;->getDefaultType()Ljava/lang/String;
|
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
move-result-object v2
|
2019-08-30 20:04:20 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-static {v2}, Ljava/security/KeyStore;->getInstance(Ljava/lang/String;)Ljava/security/KeyStore;
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
move-result-object v2
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-virtual {v2, v0}, Ljava/security/KeyStore;->load(Ljava/security/KeyStore$LoadStoreParameter;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
|
|
|
|
const-string v3, "caCert"
|
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-virtual {v2, v3, p1}, Ljava/security/KeyStore;->setCertificateEntry(Ljava/lang/String;Ljava/security/cert/Certificate;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-virtual {v1, v2}, Ljavax/net/ssl/TrustManagerFactory;->init(Ljava/security/KeyStore;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-08-30 20:04:20 +00:00
|
|
|
const-string p1, "tmf"
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-18 07:41:41 +00:00
|
|
|
invoke-static {v1, p1}, Lm/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
:try_end_0
|
|
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-static {p0, v0}, Le/k/a/b/e/p/g;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
return-object v1
|
2019-07-24 11:27:29 +00:00
|
|
|
|
|
|
|
:cond_0
|
|
|
|
:try_start_1
|
2019-12-18 07:41:41 +00:00
|
|
|
new-instance p1, Lm/l;
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-08-30 20:04:20 +00:00
|
|
|
const-string v0, "null cannot be cast to non-null type java.security.cert.X509Certificate"
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-18 07:41:41 +00:00
|
|
|
invoke-direct {p1, v0}, Lm/l;-><init>(Ljava/lang/String;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-08-30 20:04:20 +00:00
|
|
|
throw p1
|
2019-07-24 11:27:29 +00:00
|
|
|
:try_end_1
|
|
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
|
|
|
|
:catchall_0
|
|
|
|
move-exception p1
|
|
|
|
|
|
|
|
:try_start_2
|
|
|
|
throw p1
|
|
|
|
:try_end_2
|
2019-08-30 20:04:20 +00:00
|
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_1
|
|
|
|
|
|
|
|
:catchall_1
|
|
|
|
move-exception v0
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-static {p0, p1}, Le/k/a/b/e/p/g;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
|
|
|
|
|
|
|
throw v0
|
|
|
|
|
|
|
|
:cond_1
|
|
|
|
const-string p0, "certificatePath"
|
|
|
|
|
2019-12-18 07:41:41 +00:00
|
|
|
invoke-static {p0}, Lm/u/b/j;->a(Ljava/lang/String;)V
|
2019-12-06 03:29:40 +00:00
|
|
|
|
|
|
|
throw v0
|
|
|
|
|
|
|
|
:cond_2
|
|
|
|
const-string p0, "assetManager"
|
|
|
|
|
2019-12-18 07:41:41 +00:00
|
|
|
invoke-static {p0}, Lm/u/b/j;->a(Ljava/lang/String;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
|
|
|
|
throw v0
|
|
|
|
.end method
|
|
|
|
|
|
|
|
|
|
|
|
# virtual methods
|
|
|
|
.method public final init(Landroid/app/Application;)V
|
2019-12-06 03:29:40 +00:00
|
|
|
.locals 0
|
2019-07-24 11:27:29 +00:00
|
|
|
|
2019-12-06 03:29:40 +00:00
|
|
|
if-eqz p1, :cond_0
|
2019-07-24 11:27:29 +00:00
|
|
|
|
|
|
|
:try_start_0
|
2019-12-06 03:29:40 +00:00
|
|
|
invoke-static {p1}, Le/k/a/b/m/a;->a(Landroid/content/Context;)V
|
2019-07-24 11:27:29 +00:00
|
|
|
:try_end_0
|
|
|
|
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
|
|
|
|
:catch_0
|
|
|
|
return-void
|
2019-12-06 03:29:40 +00:00
|
|
|
|
|
|
|
:cond_0
|
|
|
|
const-string p1, "application"
|
|
|
|
|
2019-12-18 07:41:41 +00:00
|
|
|
invoke-static {p1}, Lm/u/b/j;->a(Ljava/lang/String;)V
|
2019-12-06 03:29:40 +00:00
|
|
|
|
|
|
|
const/4 p1, 0x0
|
|
|
|
|
|
|
|
throw p1
|
2019-07-24 11:27:29 +00:00
|
|
|
.end method
|