[App] Disable SSLProvider in Google Play builds.

This commit is contained in:
Kuba Szczodrzyński 2022-02-21 20:36:11 +01:00
parent 5b5dc5cade
commit 1bf0679e92
No known key found for this signature in database
GPG Key ID: 70CB8A85BA1633CB
4 changed files with 58 additions and 17 deletions

View File

@ -183,7 +183,8 @@ dependencies {
implementation "eu.szkolny:mhttp:af4b62e6e9"
implementation "eu.szkolny:nachos:0e5dfcaceb"
implementation "eu.szkolny.selective-dao:annotation:27f8f3f194"
implementation "eu.szkolny:ssl-provider:1.0.0"
officialImplementation "eu.szkolny:ssl-provider:1.0.0"
unofficialImplementation "eu.szkolny:ssl-provider:1.0.0"
implementation "pl.szczodrzynski:navlib:0.8.0"
implementation "pl.szczodrzynski:numberslidingpicker:2921225f76"
implementation "pl.szczodrzynski:recyclertablayout:700f980584"

View File

@ -26,8 +26,6 @@ import com.google.firebase.messaging.FirebaseMessaging
import com.google.gson.Gson
import com.hypertrack.hyperlog.HyperLog
import com.mikepenz.iconics.Iconics
import eu.szkolny.sslprovider.SSLProvider
import eu.szkolny.sslprovider.enableSupportedTls
import im.wangchao.mhttp.MHttp
import kotlinx.coroutines.*
import me.leolin.shortcutbadger.ShortcutBadger
@ -42,6 +40,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Profile
import pl.szczodrzynski.edziennik.ext.DAY
import pl.szczodrzynski.edziennik.ext.MS
import pl.szczodrzynski.edziennik.ext.setLanguage
import pl.szczodrzynski.edziennik.network.SSLProviderInstaller
import pl.szczodrzynski.edziennik.network.cookie.DumbCookieJar
import pl.szczodrzynski.edziennik.sync.SyncWorker
import pl.szczodrzynski.edziennik.sync.UpdateWorker
@ -49,7 +48,6 @@ import pl.szczodrzynski.edziennik.ui.base.CrashActivity
import pl.szczodrzynski.edziennik.utils.*
import pl.szczodrzynski.edziennik.utils.Utils.d
import pl.szczodrzynski.edziennik.utils.managers.*
import timber.log.Timber
import java.util.concurrent.TimeUnit
import kotlin.coroutines.CoroutineContext
@ -119,7 +117,8 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
.connectTimeout(15, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.enableSupportedTls(enableCleartext = true)
SSLProviderInstaller.enableSupportedTls(builder, enableCleartext = true)
if (devMode) {
HyperLog.initialize(this)
@ -203,18 +202,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
withContext(Dispatchers.Default) {
config.migrate(this@App)
SSLProvider.install(
applicationContext,
downloadIfNeeded = true,
supportTls13 = false,
onFinish = {
buildHttp()
},
onError = {
Timber.e("Failed to install SSLProvider: $it")
it.printStackTrace()
}
)
SSLProviderInstaller.install(applicationContext, this@App::buildHttp)
if (config.devModePassword != null)
checkDevModePassword()

View File

@ -0,0 +1,33 @@
/*
* Copyright (c) Kuba Szczodrzyński 2022-2-21.
*/
package pl.szczodrzynski.edziennik.network
import android.content.Context
import eu.szkolny.sslprovider.SSLProvider
import eu.szkolny.sslprovider.enableSupportedTls
import okhttp3.OkHttpClient
import timber.log.Timber
object SSLProviderInstaller {
fun install(applicationContext: Context, rebuildCallback: () -> Unit) {
SSLProvider.install(
applicationContext,
downloadIfNeeded = true,
supportTls13 = false,
onFinish = {
rebuildCallback()
},
onError = {
Timber.e("Failed to install SSLProvider: $it")
it.printStackTrace()
}
)
}
fun enableSupportedTls(builder: OkHttpClient.Builder, enableCleartext: Boolean = true) {
builder.enableSupportedTls(enableCleartext)
}
}

View File

@ -0,0 +1,19 @@
/*
* Copyright (c) Kuba Szczodrzyński 2022-2-21.
*/
package pl.szczodrzynski.edziennik.network
import android.content.Context
import okhttp3.OkHttpClient
object SSLProviderInstaller {
fun install(applicationContext: Context, rebuildCallback: () -> Unit) {
}
fun enableSupportedTls(builder: OkHttpClient.Builder, enableCleartext: Boolean = true) {
}
}