Skip to content

Commit be05b83

Browse files
committed
fix: kitkat fix (ssl errors)
1 parent 3fdbd94 commit be05b83

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/https.android.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,17 @@ function getClient(
260260
reload: boolean = false,
261261
timeout: number = 10
262262
): okhttp3.OkHttpClient {
263+
if (!Client) {
264+
// ssl error fix on KitKat. Only need to be done once.
265+
// client will be null only onced so will run only once
266+
const version = android.os.Build.VERSION.SDK_INT;
267+
if (version >= 16 && version < 22) {
268+
java.security.Security.insertProviderAt(
269+
(org as any).conscrypt.Conscrypt.newProvider(),
270+
1
271+
);
272+
}
273+
}
263274
// if (!Client) {
264275
// Client = new okhttp3.OkHttpClient()
265276
// }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
dependencies {
22
def okHttpVersion = project.hasProperty("okHttpVersion") ? project.okHttpVersion : "3.14.7"
33
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
4+
def conscryptVersion = project.hasProperty("conscryptVersion") ? project.conscryptVersion : "2.4.0"
5+
implementation "org.conscrypt:conscrypt-android:$conscryptVersion"
46
}

0 commit comments

Comments
 (0)