首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android 11 -无法提取AndroidPlatform上的信任管理器,sslSocketFactory是类sslSocketFactory。

Android 11 -无法提取AndroidPlatform上的信任管理器,sslSocketFactory是类sslSocketFactory。
EN

Stack Overflow用户
提问于 2021-02-01 14:16:01
回答 1查看 1.8K关注 0票数 2

Android 11 -无法提取AndroidPlatform上的信任管理器,sslSocketFactory是类sslSocketFactory。

问题仅与Android 11设备

有关。

EN

回答 1

Stack Overflow用户

发布于 2021-02-01 19:32:59

您正在调用一个不推荐的方法https://github.com/square/okhttp/blob/fce60e5a09eac198a0f9c676e486163212662230/okhttp/src/main/kotlin/okhttp3/OkHttpClient.kt#L761

代码语言:javascript
复制
    /**
     * Sets the socket factory used to secure HTTPS connections. If unset, the system default will
     * be used.
     *
     * @deprecated [SSLSocketFactory] does not expose its [X509TrustManager], which is a field that
     *     OkHttp needs to build a clean certificate chain. This method instead must use reflection
     *     to extract the trust manager. Applications should prefer to call
     *     `sslSocketFactory(SSLSocketFactory, X509TrustManager)`, which avoids such reflection.
     */
    @Deprecated(
        message = "Use the sslSocketFactory overload that accepts a X509TrustManager.",
        level = DeprecationLevel.ERROR
    )
    fun sslSocketFactory(sslSocketFactory: SSLSocketFactory) = apply {
      if (sslSocketFactory != this.sslSocketFactoryOrNull) {
        this.routeDatabase = null
      }

      this.sslSocketFactoryOrNull = sslSocketFactory
      this.x509TrustManagerOrNull = Platform.get().trustManager(sslSocketFactory) ?: throw IllegalStateException(
          "Unable to extract the trust manager on ${Platform.get()}, " +
              "sslSocketFactory is ${sslSocketFactory.javaClass}")
      this.certificateChainCleaner = Platform.get().buildCertificateChainCleaner(x509TrustManagerOrNull!!)
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65994280

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档