![](/img/trans.png)
[英]java.lang.IllegalStateException: Unable to extract the trust manager on AndroidPlatform, sslSocketFactory
[英]Android 11 - Unable to extract the trust manager on AndroidPlatform, sslSocketFactory is class com.android.org.conscrypt.OpenSSLSocketFactoryImpl
Android 11 - Unable to extract the trust manager on AndroidPlatform, sslSocketFactory is class com.android.org.conscrypt.OpenSSLSocketFactoryImpl
問題僅適用於 Android 11 設備
/**
* 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!!)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.