Skip to content

AndroidPlatform.trustManager() not using ClassLoader from delegate object #2827

@stevelilly-tw

Description

@stevelilly-tw

I am seeing a very similar crash to #2323, reproducible on KitKat and Marshmellow, i.e.:

java.lang.IllegalStateException: Unable to extract the trust manager on okhttp3.internal.platform.AndroidPlatform@b1a3a6d8, sslSocketFactory is class com.paypal.android.sdk.cg
                                                                                at okhttp3.OkHttpClient$Builder.sslSocketFactory(OkHttpClient.java:599)
                                                                                at com.paypal.android.sdk.cc.a(Unknown Source)
                                                                                at com.paypal.android.sdk.cm.<init>(Unknown Source)
                                                                                at com.paypal.android.sdk.payments.PayPalService.a(Unknown Source)
                                                                                at com.paypal.android.sdk.payments.PayPalService.onBind(Unknown Source)

From what I can tell, for me the fallback mechanism inside AndroidPlatform.trustManager() is trying to work, i.e.:

@Override public X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) {
    Object context = readFieldOrNull(sslSocketFactory, sslParametersClass, "sslParameters");
    if (context == null) {
      // If that didn't work, try the Google Play Services SSL provider before giving up. This
      // must be loaded by the SSLSocketFactory's class loader.
      try {
        Class<?> gmsSslParametersClass = Class.forName(
            "com.google.android.gms.org.conscrypt.SSLParametersImpl", false,
            sslSocketFactory.getClass().getClassLoader());

However, it seems that the sslSocketFactory class loader can't load that class, however the sslSocketFactory.delegate class loader can load the class.

A little background: my app allows both Google and PayPal login. PayPal login from start is OK. Attempting a Google login first somehow swaps the com.android.org.conscrypt.SSLParametersImpl for a com.google.android.gms.org.conscrypt.SSLParametersImpl under the hood, after which attempting a PayPal login fails to load gmsSslParametersClass and leads to the crash.

The sslSocketFactory is provided by the PayPal SDK and so loaded from my app's classloader. The delegate seems to be able to be loaded from /system/priv-app/PrebuiltGmsCore.apk

Correct me if I'm wrong, but doesn't that code need to cater for the class loader in the delegate case as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug in existing code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions