.class public final Lokhttp3/internal/tls/OkHostnameVerifier; .super Ljava/lang/Object; .source "OkHostnameVerifier.kt" # interfaces .implements Ljavax/net/ssl/HostnameVerifier; # annotations .annotation system Ldalvik/annotation/SourceDebugExtension; value = "SMAP\nOkHostnameVerifier.kt\nKotlin\n*S Kotlin\n*F\n+ 1 OkHostnameVerifier.kt\nokhttp3/internal/tls/OkHostnameVerifier\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,187:1\n1691#2,3:188\n1691#2,3:191\n*E\n*S KotlinDebug\n*F\n+ 1 OkHostnameVerifier.kt\nokhttp3/internal/tls/OkHostnameVerifier\n*L\n57#1,3:188\n65#1,3:191\n*E\n" .end annotation .annotation runtime Lkotlin/Metadata; bv = { 0x1, 0x0, 0x3 } d1 = { "\u00006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0008\u0002\n\u0002\u0010\u0008\n\u0002\u0008\u0002\n\u0002\u0010 \n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0008\u0003\n\u0002\u0010\u000b\n\u0002\u0008\u0002\n\u0002\u0018\u0002\n\u0002\u0008\u0006\u0008\u00c6\u0002\u0018\u00002\u00020\u0001B\u0007\u0008\u0002\u00a2\u0006\u0002\u0010\u0002J\u0014\u0010\u0006\u001a\u0008\u0012\u0004\u0012\u00020\u00080\u00072\u0006\u0010\t\u001a\u00020\nJ\u001e\u0010\u000b\u001a\u0008\u0012\u0004\u0012\u00020\u00080\u00072\u0006\u0010\t\u001a\u00020\n2\u0006\u0010\u000c\u001a\u00020\u0004H\u0002J\u0016\u0010\r\u001a\u00020\u000e2\u0006\u0010\u000f\u001a\u00020\u00082\u0006\u0010\t\u001a\u00020\nJ\u0018\u0010\r\u001a\u00020\u000e2\u0006\u0010\u000f\u001a\u00020\u00082\u0006\u0010\u0010\u001a\u00020\u0011H\u0016J\u0018\u0010\u0012\u001a\u00020\u000e2\u0006\u0010\u0013\u001a\u00020\u00082\u0006\u0010\t\u001a\u00020\nH\u0002J\u001c\u0010\u0012\u001a\u00020\u000e2\u0008\u0010\u0013\u001a\u0004\u0018\u00010\u00082\u0008\u0010\u0014\u001a\u0004\u0018\u00010\u0008H\u0002J\u0018\u0010\u0015\u001a\u00020\u000e2\u0006\u0010\u0016\u001a\u00020\u00082\u0006\u0010\t\u001a\u00020\nH\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0004X\u0082T\u00a2\u0006\u0002\n\u0000\u00a8\u0006\u0017" } d2 = { "Lokhttp3/internal/tls/OkHostnameVerifier;", "Ljavax/net/ssl/HostnameVerifier;", "()V", "ALT_DNS_NAME", "", "ALT_IPA_NAME", "allSubjectAltNames", "", "", "certificate", "Ljava/security/cert/X509Certificate;", "getSubjectAltNames", "type", "verify", "", "host", "session", "Ljavax/net/ssl/SSLSession;", "verifyHostname", "hostname", "pattern", "verifyIpAddress", "ipAddress", "okhttp" } k = 0x1 mv = { 0x1, 0x4, 0x0 } .end annotation # static fields .field private static final ALT_DNS_NAME:I = 0x2 .field private static final ALT_IPA_NAME:I = 0x7 .field public static final INSTANCE:Lokhttp3/internal/tls/OkHostnameVerifier; # direct methods .method static constructor ()V .locals 1 .line 34 new-instance v0, Lokhttp3/internal/tls/OkHostnameVerifier; invoke-direct {v0}, Lokhttp3/internal/tls/OkHostnameVerifier;->()V sput-object v0, Lokhttp3/internal/tls/OkHostnameVerifier;->INSTANCE:Lokhttp3/internal/tls/OkHostnameVerifier; return-void .end method .method private constructor ()V .locals 0 .line 34 invoke-direct {p0}, Ljava/lang/Object;->()V return-void .end method .method private final getSubjectAltNames(Ljava/security/cert/X509Certificate;I)Ljava/util/List; .locals 3 .annotation system Ldalvik/annotation/Signature; value = { "(", "Ljava/security/cert/X509Certificate;", "I)", "Ljava/util/List<", "Ljava/lang/String;", ">;" } .end annotation .line 173 :try_start_0 invoke-virtual {p1}, Ljava/security/cert/X509Certificate;->getSubjectAlternativeNames()Ljava/util/Collection; move-result-object p0 if-eqz p0, :cond_5 .line 174 new-instance p1, Ljava/util/ArrayList; invoke-direct {p1}, Ljava/util/ArrayList;->()V check-cast p1, Ljava/util/List; .line 175 invoke-interface {p0}, Ljava/util/Collection;->iterator()Ljava/util/Iterator; move-result-object p0 :cond_0 :goto_0 invoke-interface {p0}, Ljava/util/Iterator;->hasNext()Z move-result v0 if-eqz v0, :cond_4 invoke-interface {p0}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/List; if-eqz v0, :cond_0 .line 176 invoke-interface {v0}, Ljava/util/List;->size()I move-result v1 const/4 v2, 0x2 if-ge v1, v2, :cond_1 goto :goto_0 :cond_1 const/4 v1, 0x0 .line 177 invoke-interface {v0, v1}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v1 invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer; move-result-object v2 invoke-static {v1, v2}, Lkotlin/jvm/internal/Intrinsics;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z move-result v1 const/4 v2, 0x1 xor-int/2addr v1, v2 if-eqz v1, :cond_2 goto :goto_0 .line 178 :cond_2 invoke-interface {v0, v2}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v0 if-eqz v0, :cond_0 if-eqz v0, :cond_3 .line 179 check-cast v0, Ljava/lang/String; invoke-interface {p1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z goto :goto_0 :cond_3 new-instance p0, Ljava/lang/NullPointerException; const-string p1, "null cannot be cast to non-null type kotlin.String" invoke-direct {p0, p1}, Ljava/lang/NullPointerException;->(Ljava/lang/String;)V throw p0 :cond_4 return-object p1 .line 173 :cond_5 invoke-static {}, Lkotlin/collections/CollectionsKt;->emptyList()Ljava/util/List; move-result-object p0 :try_end_0 .catch Ljava/security/cert/CertificateParsingException; {:try_start_0 .. :try_end_0} :catch_0 return-object p0 .line 183 :catch_0 invoke-static {}, Lkotlin/collections/CollectionsKt;->emptyList()Ljava/util/List; move-result-object p0 return-object p0 .end method .method private final verifyHostname(Ljava/lang/String;Ljava/lang/String;)Z .locals 12 .line 81 move-object p0, p1 check-cast p0, Ljava/lang/CharSequence; const/4 v0, 0x0 if-eqz p0, :cond_f invoke-interface {p0}, Ljava/lang/CharSequence;->length()I move-result p0 if-nez p0, :cond_0 goto/16 :goto_1 :cond_0 const-string p0, "." const/4 v1, 0x2 const/4 v2, 0x0 .line 82 invoke-static {p1, p0, v0, v1, v2}, Lkotlin/text/StringsKt;->startsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z move-result v3 if-nez v3, :cond_f const-string v3, ".." .line 83 invoke-static {p1, v3, v0, v1, v2}, Lkotlin/text/StringsKt;->endsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z move-result v4 if-eqz v4, :cond_1 goto/16 :goto_1 .line 87 :cond_1 move-object v4, p2 check-cast v4, Ljava/lang/CharSequence; if-eqz v4, :cond_f invoke-interface {v4}, Ljava/lang/CharSequence;->length()I move-result v4 if-nez v4, :cond_2 goto/16 :goto_1 .line 88 :cond_2 invoke-static {p2, p0, v0, v1, v2}, Lkotlin/text/StringsKt;->startsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z move-result v4 if-nez v4, :cond_f .line 89 invoke-static {p2, v3, v0, v1, v2}, Lkotlin/text/StringsKt;->endsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z move-result v3 if-eqz v3, :cond_3 goto/16 :goto_1 .line 103 :cond_3 invoke-static {p1, p0, v0, v1, v2}, Lkotlin/text/StringsKt;->endsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z move-result v3 if-nez v3, :cond_4 .line 104 new-instance v3, Ljava/lang/StringBuilder; invoke-direct {v3}, Ljava/lang/StringBuilder;->()V invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object p1 invoke-virtual {p1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object p1 invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object p1 .line 106 :cond_4 invoke-static {p2, p0, v0, v1, v2}, Lkotlin/text/StringsKt;->endsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z move-result v3 if-nez v3, :cond_5 .line 107 new-instance v3, Ljava/lang/StringBuilder; invoke-direct {v3}, Ljava/lang/StringBuilder;->()V invoke-virtual {v3, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object p2 invoke-virtual {p2, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object p0 invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object p2 .line 111 :cond_5 sget-object p0, Ljava/util/Locale;->US:Ljava/util/Locale; const-string v3, "Locale.US" invoke-static {p0, v3}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V const-string v3, "null cannot be cast to non-null type java.lang.String" if-eqz p2, :cond_e invoke-virtual {p2, p0}, Ljava/lang/String;->toLowerCase(Ljava/util/Locale;)Ljava/lang/String; move-result-object p0 const-string p2, "(this as java.lang.String).toLowerCase(locale)" invoke-static {p0, p2}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V .line 114 move-object v4, p0 check-cast v4, Ljava/lang/CharSequence; const-string p2, "*" check-cast p2, Ljava/lang/CharSequence; invoke-static {v4, p2, v0, v1, v2}, Lkotlin/text/StringsKt;->contains$default(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z move-result p2 if-nez p2, :cond_6 .line 116 invoke-static {p1, p0}, Lkotlin/jvm/internal/Intrinsics;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z move-result p0 return p0 :cond_6 const-string p2, "*." .line 131 invoke-static {p0, p2, v0, v1, v2}, Lkotlin/text/StringsKt;->startsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z move-result v5 if-eqz v5, :cond_d const/16 v5, 0x2a const/4 v6, 0x1 const/4 v7, 0x0 const/4 v8, 0x4 const/4 v9, 0x0 invoke-static/range {v4 .. v9}, Lkotlin/text/StringsKt;->indexOf$default(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I move-result v4 const/4 v5, -0x1 if-eq v4, v5, :cond_7 goto :goto_0 .line 140 :cond_7 invoke-virtual {p1}, Ljava/lang/String;->length()I move-result v4 invoke-virtual {p0}, Ljava/lang/String;->length()I move-result v6 if-ge v4, v6, :cond_8 return v0 .line 144 :cond_8 invoke-static {p2, p0}, Lkotlin/jvm/internal/Intrinsics;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z move-result p2 if-eqz p2, :cond_9 return v0 :cond_9 if-eqz p0, :cond_c const/4 p2, 0x1 .line 149 invoke-virtual {p0, p2}, Ljava/lang/String;->substring(I)Ljava/lang/String; move-result-object p0 const-string v3, "(this as java.lang.String).substring(startIndex)" invoke-static {p0, v3}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V .line 150 invoke-static {p1, p0, v0, v1, v2}, Lkotlin/text/StringsKt;->endsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z move-result v1 if-nez v1, :cond_a return v0 .line 155 :cond_a invoke-virtual {p1}, Ljava/lang/String;->length()I move-result v1 invoke-virtual {p0}, Ljava/lang/String;->length()I move-result p0 sub-int/2addr v1, p0 if-lez v1, :cond_b .line 157 move-object v6, p1 check-cast v6, Ljava/lang/CharSequence; const/16 v7, 0x2e add-int/lit8 v8, v1, -0x1 const/4 v9, 0x0 const/4 v10, 0x4 const/4 v11, 0x0 invoke-static/range {v6 .. v11}, Lkotlin/text/StringsKt;->lastIndexOf$default(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I move-result p0 if-eq p0, v5, :cond_b return v0 :cond_b return p2 .line 149 :cond_c new-instance p0, Ljava/lang/NullPointerException; invoke-direct {p0, v3}, Ljava/lang/NullPointerException;->(Ljava/lang/String;)V throw p0 :cond_d :goto_0 return v0 .line 111 :cond_e new-instance p0, Ljava/lang/NullPointerException; invoke-direct {p0, v3}, Ljava/lang/NullPointerException;->(Ljava/lang/String;)V throw p0 :cond_f :goto_1 return v0 .end method .method private final verifyHostname(Ljava/lang/String;Ljava/security/cert/X509Certificate;)Z .locals 2 .line 64 sget-object v0, Ljava/util/Locale;->US:Ljava/util/Locale; const-string v1, "Locale.US" invoke-static {v0, v1}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V if-eqz p1, :cond_3 invoke-virtual {p1, v0}, Ljava/lang/String;->toLowerCase(Ljava/util/Locale;)Ljava/lang/String; move-result-object p1 const-string v0, "(this as java.lang.String).toLowerCase(locale)" invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V const/4 v0, 0x2 .line 65 invoke-direct {p0, p2, v0}, Lokhttp3/internal/tls/OkHostnameVerifier;->getSubjectAltNames(Ljava/security/cert/X509Certificate;I)Ljava/util/List; move-result-object p0 check-cast p0, Ljava/lang/Iterable; .line 191 instance-of p2, p0, Ljava/util/Collection; const/4 v0, 0x0 if-eqz p2, :cond_0 move-object p2, p0 check-cast p2, Ljava/util/Collection; invoke-interface {p2}, Ljava/util/Collection;->isEmpty()Z move-result p2 if-eqz p2, :cond_0 goto :goto_0 .line 192 :cond_0 invoke-interface {p0}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator; move-result-object p0 :cond_1 invoke-interface {p0}, Ljava/util/Iterator;->hasNext()Z move-result p2 if-eqz p2, :cond_2 invoke-interface {p0}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object p2 check-cast p2, Ljava/lang/String; sget-object v1, Lokhttp3/internal/tls/OkHostnameVerifier;->INSTANCE:Lokhttp3/internal/tls/OkHostnameVerifier; .line 66 invoke-direct {v1, p1, p2}, Lokhttp3/internal/tls/OkHostnameVerifier;->verifyHostname(Ljava/lang/String;Ljava/lang/String;)Z move-result p2 if-eqz p2, :cond_1 const/4 v0, 0x1 :cond_2 :goto_0 return v0 .line 64 :cond_3 new-instance p0, Ljava/lang/NullPointerException; const-string p1, "null cannot be cast to non-null type java.lang.String" invoke-direct {p0, p1}, Ljava/lang/NullPointerException;->(Ljava/lang/String;)V throw p0 .end method .method private final verifyIpAddress(Ljava/lang/String;Ljava/security/cert/X509Certificate;)Z .locals 1 .line 55 invoke-static {p1}, Lokhttp3/internal/HostnamesKt;->toCanonicalHost(Ljava/lang/String;)Ljava/lang/String; move-result-object p1 const/4 v0, 0x7 .line 57 invoke-direct {p0, p2, v0}, Lokhttp3/internal/tls/OkHostnameVerifier;->getSubjectAltNames(Ljava/security/cert/X509Certificate;I)Ljava/util/List; move-result-object p0 check-cast p0, Ljava/lang/Iterable; .line 188 instance-of p2, p0, Ljava/util/Collection; const/4 v0, 0x0 if-eqz p2, :cond_0 move-object p2, p0 check-cast p2, Ljava/util/Collection; invoke-interface {p2}, Ljava/util/Collection;->isEmpty()Z move-result p2 if-eqz p2, :cond_0 goto :goto_0 .line 189 :cond_0 invoke-interface {p0}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator; move-result-object p0 :cond_1 invoke-interface {p0}, Ljava/util/Iterator;->hasNext()Z move-result p2 if-eqz p2, :cond_2 invoke-interface {p0}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object p2 check-cast p2, Ljava/lang/String; .line 58 invoke-static {p2}, Lokhttp3/internal/HostnamesKt;->toCanonicalHost(Ljava/lang/String;)Ljava/lang/String; move-result-object p2 invoke-static {p1, p2}, Lkotlin/jvm/internal/Intrinsics;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z move-result p2 if-eqz p2, :cond_1 const/4 v0, 0x1 :cond_2 :goto_0 return v0 .end method # virtual methods .method public final allSubjectAltNames(Ljava/security/cert/X509Certificate;)Ljava/util/List; .locals 2 .annotation system Ldalvik/annotation/Signature; value = { "(", "Ljava/security/cert/X509Certificate;", ")", "Ljava/util/List<", "Ljava/lang/String;", ">;" } .end annotation const-string v0, "certificate" invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V const/4 v0, 0x7 .line 166 invoke-direct {p0, p1, v0}, Lokhttp3/internal/tls/OkHostnameVerifier;->getSubjectAltNames(Ljava/security/cert/X509Certificate;I)Ljava/util/List; move-result-object v0 const/4 v1, 0x2 .line 167 invoke-direct {p0, p1, v1}, Lokhttp3/internal/tls/OkHostnameVerifier;->getSubjectAltNames(Ljava/security/cert/X509Certificate;I)Ljava/util/List; move-result-object p0 .line 168 check-cast v0, Ljava/util/Collection; check-cast p0, Ljava/lang/Iterable; invoke-static {v0, p0}, Lkotlin/collections/CollectionsKt;->plus(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List; move-result-object p0 return-object p0 .end method .method public final verify(Ljava/lang/String;Ljava/security/cert/X509Certificate;)Z .locals 1 const-string v0, "host" invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V const-string v0, "certificate" invoke-static {p2, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V .line 48 invoke-static {p1}, Lokhttp3/internal/Util;->canParseAsIpAddress(Ljava/lang/String;)Z move-result v0 if-eqz v0, :cond_0 invoke-direct {p0, p1, p2}, Lokhttp3/internal/tls/OkHostnameVerifier;->verifyIpAddress(Ljava/lang/String;Ljava/security/cert/X509Certificate;)Z move-result p0 goto :goto_0 .line 49 :cond_0 invoke-direct {p0, p1, p2}, Lokhttp3/internal/tls/OkHostnameVerifier;->verifyHostname(Ljava/lang/String;Ljava/security/cert/X509Certificate;)Z move-result p0 :goto_0 return p0 .end method .method public verify(Ljava/lang/String;Ljavax/net/ssl/SSLSession;)Z .locals 1 const-string v0, "host" invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V const-string v0, "session" invoke-static {p2, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V const/4 v0, 0x0 .line 40 :try_start_0 invoke-interface {p2}, Ljavax/net/ssl/SSLSession;->getPeerCertificates()[Ljava/security/cert/Certificate; move-result-object p2 aget-object p2, p2, v0 if-eqz p2, :cond_0 check-cast p2, Ljava/security/cert/X509Certificate; invoke-virtual {p0, p1, p2}, Lokhttp3/internal/tls/OkHostnameVerifier;->verify(Ljava/lang/String;Ljava/security/cert/X509Certificate;)Z move-result v0 goto :goto_0 :cond_0 new-instance p0, Ljava/lang/NullPointerException; const-string p1, "null cannot be cast to non-null type java.security.cert.X509Certificate" invoke-direct {p0, p1}, Ljava/lang/NullPointerException;->(Ljava/lang/String;)V throw p0 :try_end_0 .catch Ljavax/net/ssl/SSLException; {:try_start_0 .. :try_end_0} :catch_0 :catch_0 :goto_0 return v0 .end method