SslClient.smali 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. .class public final Lokhttp3/internal/tls/SslClient;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/MemberClasses;
  6. value = {
  7. Lokhttp3/internal/tls/SslClient$Builder;
  8. }
  9. .end annotation
  10. # static fields
  11. .field private static localhost:Lokhttp3/internal/tls/SslClient;
  12. # instance fields
  13. .field public final socketFactory:Ljavax/net/ssl/SSLSocketFactory;
  14. .field public final sslContext:Ljavax/net/ssl/SSLContext;
  15. .field public final trustManager:Ljavax/net/ssl/X509TrustManager;
  16. # direct methods
  17. .method private constructor <init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/X509TrustManager;)V
  18. .locals 0
  19. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  20. iput-object p1, p0, Lokhttp3/internal/tls/SslClient;->sslContext:Ljavax/net/ssl/SSLContext;
  21. invoke-virtual {p1}, Ljavax/net/ssl/SSLContext;->getSocketFactory()Ljavax/net/ssl/SSLSocketFactory;
  22. move-result-object p1
  23. iput-object p1, p0, Lokhttp3/internal/tls/SslClient;->socketFactory:Ljavax/net/ssl/SSLSocketFactory;
  24. iput-object p2, p0, Lokhttp3/internal/tls/SslClient;->trustManager:Ljavax/net/ssl/X509TrustManager;
  25. return-void
  26. .end method
  27. .method synthetic constructor <init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/X509TrustManager;Lokhttp3/internal/tls/SslClient$1;)V
  28. .locals 0
  29. invoke-direct {p0, p1, p2}, Lokhttp3/internal/tls/SslClient;-><init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/X509TrustManager;)V
  30. return-void
  31. .end method
  32. .method public static declared-synchronized localhost()Lokhttp3/internal/tls/SslClient;
  33. .locals 6
  34. const-class v0, Lokhttp3/internal/tls/SslClient;
  35. monitor-enter v0
  36. :try_start_0
  37. sget-object v1, Lokhttp3/internal/tls/SslClient;->localhost:Lokhttp3/internal/tls/SslClient;
  38. if-eqz v1, :cond_0
  39. sget-object v1, Lokhttp3/internal/tls/SslClient;->localhost:Lokhttp3/internal/tls/SslClient;
  40. :try_end_0
  41. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  42. monitor-exit v0
  43. return-object v1
  44. :cond_0
  45. :try_start_1
  46. new-instance v1, Lokhttp3/internal/tls/HeldCertificate$Builder;
  47. invoke-direct {v1}, Lokhttp3/internal/tls/HeldCertificate$Builder;-><init>()V
  48. const-string v2, "1"
  49. invoke-virtual {v1, v2}, Lokhttp3/internal/tls/HeldCertificate$Builder;->serialNumber(Ljava/lang/String;)Lokhttp3/internal/tls/HeldCertificate$Builder;
  50. move-result-object v1
  51. const-string v2, "localhost"
  52. invoke-static {v2}, Ljava/net/InetAddress;->getByName(Ljava/lang/String;)Ljava/net/InetAddress;
  53. move-result-object v2
  54. invoke-virtual {v2}, Ljava/net/InetAddress;->getCanonicalHostName()Ljava/lang/String;
  55. move-result-object v2
  56. invoke-virtual {v1, v2}, Lokhttp3/internal/tls/HeldCertificate$Builder;->commonName(Ljava/lang/String;)Lokhttp3/internal/tls/HeldCertificate$Builder;
  57. move-result-object v1
  58. invoke-virtual {v1}, Lokhttp3/internal/tls/HeldCertificate$Builder;->build()Lokhttp3/internal/tls/HeldCertificate;
  59. move-result-object v1
  60. new-instance v2, Lokhttp3/internal/tls/SslClient$Builder;
  61. invoke-direct {v2}, Lokhttp3/internal/tls/SslClient$Builder;-><init>()V
  62. iget-object v3, v1, Lokhttp3/internal/tls/HeldCertificate;->keyPair:Ljava/security/KeyPair;
  63. iget-object v4, v1, Lokhttp3/internal/tls/HeldCertificate;->certificate:Ljava/security/cert/X509Certificate;
  64. const/4 v5, 0x0
  65. new-array v5, v5, [Ljava/security/cert/X509Certificate;
  66. invoke-virtual {v2, v3, v4, v5}, Lokhttp3/internal/tls/SslClient$Builder;->certificateChain(Ljava/security/KeyPair;Ljava/security/cert/X509Certificate;[Ljava/security/cert/X509Certificate;)Lokhttp3/internal/tls/SslClient$Builder;
  67. move-result-object v2
  68. iget-object v1, v1, Lokhttp3/internal/tls/HeldCertificate;->certificate:Ljava/security/cert/X509Certificate;
  69. invoke-virtual {v2, v1}, Lokhttp3/internal/tls/SslClient$Builder;->addTrustedCertificate(Ljava/security/cert/X509Certificate;)Lokhttp3/internal/tls/SslClient$Builder;
  70. move-result-object v1
  71. invoke-virtual {v1}, Lokhttp3/internal/tls/SslClient$Builder;->build()Lokhttp3/internal/tls/SslClient;
  72. move-result-object v1
  73. sput-object v1, Lokhttp3/internal/tls/SslClient;->localhost:Lokhttp3/internal/tls/SslClient;
  74. sget-object v1, Lokhttp3/internal/tls/SslClient;->localhost:Lokhttp3/internal/tls/SslClient;
  75. :try_end_1
  76. .catch Ljava/security/GeneralSecurityException; {:try_start_1 .. :try_end_1} :catch_1
  77. .catch Ljava/net/UnknownHostException; {:try_start_1 .. :try_end_1} :catch_0
  78. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  79. monitor-exit v0
  80. return-object v1
  81. :catch_0
  82. move-exception v1
  83. goto :goto_0
  84. :catch_1
  85. move-exception v1
  86. :goto_0
  87. :try_start_2
  88. new-instance v2, Ljava/lang/RuntimeException;
  89. invoke-direct {v2, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/Throwable;)V
  90. throw v2
  91. :try_end_2
  92. .catchall {:try_start_2 .. :try_end_2} :catchall_0
  93. :catchall_0
  94. move-exception v1
  95. monitor-exit v0
  96. throw v1
  97. .end method