Okhttp: IllegalArgumentException: Not a Conscrypt trust manager: android.security.net.config.RootTrustManager

Created on 19 May 2020  Â·  6Comments  Â·  Source: square/okhttp

since release 4.7.0 and also for 4.7.1 i get the following exception when using the OkHttpClient.

2020-05-19 13:15:39.061 13971-14060/fr.gaulupeau.apps.InThePoche.debug E/ArticleUpdateWorker: updateArticles() exception
    java.lang.IllegalArgumentException: Not a Conscrypt trust manager: android.security.net.config.RootTrustManager
        at org.conscrypt.Conscrypt.toConscrypt(Conscrypt.java:736)
        at org.conscrypt.Conscrypt.setHostnameVerifier(Conscrypt.java:769)
        at okhttp3.internal.platform.ConscryptPlatform.platformTrustManager(ConscryptPlatform.kt:53)
        at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:237)
        at okhttp3.OkHttpClient$Builder.build(OkHttpClient.kt:1069)
        at fr.gaulupeau.apps.Poche.network.WallabagConnection.createClient(WallabagConnection.java:123)
        at fr.gaulupeau.apps.Poche.network.WallabagConnection.createWallabagService(WallabagConnection.java:107)
        at fr.gaulupeau.apps.Poche.network.WallabagConnection.getWallabagService(WallabagConnection.java:38)
        at fr.gaulupeau.apps.Poche.service.workers.BaseNetworkWorker.getWallabagService(BaseNetworkWorker.java:86)
        at fr.gaulupeau.apps.Poche.service.workers.ArticleUpdateWorker.updateArticles(ArticleUpdateWorker.java:76)
        at fr.gaulupeau.apps.Poche.service.workers.ArticleUpdateWorker.update(ArticleUpdateWorker.java:37)
        at fr.gaulupeau.apps.Poche.service.tasks.UpdateArticlesTask.run(UpdateArticlesTask.java:17)
        at fr.gaulupeau.apps.Poche.service.tasks.ActionRequestTask.run(ActionRequestTask.java:25)
        at fr.gaulupeau.apps.Poche.service.-$$Lambda$Eg7UQkyPgCNRHvigqxzb-ridugA.run(Unknown Source:2)
        at fr.gaulupeau.apps.Poche.service.TaskService.run(TaskService.java:158)
        at fr.gaulupeau.apps.Poche.service.TaskService.lambda$gjfracnqY8x0_-mrxsx0oqjQmgk(Unknown Source:0)
        at fr.gaulupeau.apps.Poche.service.-$$Lambda$TaskService$gjfracnqY8x0_-mrxsx0oqjQmgk.run(Unknown Source:2)
        at java.lang.Thread.run(Thread.java:919)

We create the client like this (simplified from here):

OkHttpClient.Builder b = new OkHttpClient.Builder()
                .readTimeout(45, TimeUnit.SECONDS);
b.build();

This issue does not occur with release 4.6.0 or 4.5.0.

Is this a bug? Or do you have an idea how i can fix this exception?

android bug needs info

All 6 comments

Some additional info: the project is an Android application which uses the Conscrypt library.

Minimal case:

    implementation 'org.conscrypt:conscrypt-android:2.4.0'
    implementation 'com.squareup.okhttp3:okhttp:4.7.1'
        Security.insertProviderAt(Conscrypt.newProvider(), 1);

        new OkHttpClient();

The core issue here is the Platform check seems to be failing and we are trying to use Conscrypt JVM provider on Android.

Just found the env details on the linked bug, thanks.

wallabag app version: master f37abc7
wallabag app installation source (e.g. Gplay, F-Droid, manual): manual
Android OS version: 10
Android ROM (e.g. stock, LineageOS, SlimRom,…): stock
Android hardware: Samsung S9
wallabag server version: 2.3.8
Do you have Two-Factor-Authentication enabled?: no

This project provides a trivial repro of the issue. It's a bug with the initialisation ordering of the fields of companion classes. My bad.

https://github.com/wallabag/android-app

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SandroMachado picture SandroMachado  Â·  3Comments

mleibner picture mleibner  Â·  3Comments

GuiForget picture GuiForget  Â·  3Comments

dannyZhou picture dannyZhou  Â·  3Comments

yschimke picture yschimke  Â·  3Comments