From 6140026d29dac0cc9c2374cfb678607bb52ff3c4 Mon Sep 17 00:00:00 2001 From: Artem Chepurnyi Date: Tue, 2 Jul 2024 21:52:11 +0300 Subject: [PATCH] fix(Desktop): Use BouncyCastle as TLS provider instead of Conscrypt #447 #324 --- desktopApp/build.gradle.kts | 3 ++- .../src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt | 8 +++++--- gradle/libs.versions.toml | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/desktopApp/build.gradle.kts b/desktopApp/build.gradle.kts index 6c26dd5b..903777bc 100644 --- a/desktopApp/build.gradle.kts +++ b/desktopApp/build.gradle.kts @@ -21,7 +21,8 @@ kotlin { implementation(compose.materialIconsExtended) implementation(compose.desktop.currentOs) implementation(compose.components.resources) - implementation(libs.conscrypt.openjdk) + implementation(libs.bouncycastle.bcprov) + implementation(libs.bouncycastle.bctls) implementation(project(":common")) } } diff --git a/desktopApp/src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt b/desktopApp/src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt index 8be1dd74..ab9d32ba 100644 --- a/desktopApp/src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt +++ b/desktopApp/src/jvmMain/kotlin/com/artemchep/keyguard/Main.kt @@ -70,7 +70,8 @@ import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import kotlinx.datetime.Clock -import org.conscrypt.Conscrypt +import org.bouncycastle.jce.provider.BouncyCastleProvider +import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.resources.stringResource import org.kodein.di.DI @@ -85,11 +86,12 @@ import java.util.Locale import kotlin.reflect.KClass fun main() { - // Add Conscrypt as the first security provider + // Add BouncyCastle as the first security provider // to make OkHTTP use its TLS instead of a platform // specific one. // https://github.com/square/okhttp?tab=readme-ov-file#requirements - Security.insertProviderAt(Conscrypt.newProvider(), 1) + Security.insertProviderAt(BouncyCastleProvider(), 1) + Security.insertProviderAt(BouncyCastleJsseProvider(), 2) val kamelConfig = KamelConfig { this.takeFrom(KamelConfig.Default) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e8974b56..f393a18c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -231,6 +231,7 @@ landscapist-glide = { module = "com.github.skydoves:landscapist-glide", version. landscapist-placeholder = { module = "com.github.skydoves:landscapist-placeholder", version.ref = "landscapist" } bouncycastle-bcpkix = { module = "org.bouncycastle:bcpkix-jdk18on", version.ref = "bouncycastle" } bouncycastle-bcprov = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "bouncycastle" } +bouncycastle-bctls = { module = "org.bouncycastle:bctls-jdk18on", version.ref = "bouncycastle" } mayakapps-window-styler = { module = "com.mayakapps.compose:window-styler", version.ref = "windowStyler" } microsoft-signalr = { module = "com.microsoft.signalr:signalr", version.ref = "signalr" } microsoft-signalr-messagepack = { module = "com.microsoft.signalr.messagepack:signalr-messagepack", version.ref = "signalr" }