From 94f1ec943cf232644b67e48448d23c6cbc88a048 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sat, 27 Aug 2022 15:09:25 +0200 Subject: [PATCH] Cleaning. --- .../android/utils/HttpUtils.kt | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/HttpUtils.kt diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/HttpUtils.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/HttpUtils.kt deleted file mode 100644 index 46aa83f..0000000 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/HttpUtils.kt +++ /dev/null @@ -1,43 +0,0 @@ -package bou.amine.apps.readerforselfossv2.android.utils - -import okhttp3.OkHttpClient -import java.security.cert.CertificateException -import java.security.cert.X509Certificate -import javax.net.ssl.SSLContext -import javax.net.ssl.TrustManager -import javax.net.ssl.X509TrustManager - -fun getUnsafeHttpClient(): OkHttpClient.Builder = - try { - // Create a trust manager that does not validate certificate chains - val trustAllCerts = arrayOf(object : X509TrustManager { - override fun getAcceptedIssuers(): Array = - arrayOf() - - @Throws(CertificateException::class) - override fun checkClientTrusted( - chain: Array, - authType: String - ) { - } - - @Throws(CertificateException::class) - override fun checkServerTrusted( - chain: Array, - authType: String - ) { - } - }) - - // Install the all-trusting trust manager - val sslContext = SSLContext.getInstance("SSL") - sslContext.init(null, trustAllCerts, java.security.SecureRandom()) - - val sslSocketFactory = sslContext.socketFactory - - OkHttpClient.Builder() - .sslSocketFactory(sslSocketFactory, trustAllCerts[0] as X509TrustManager) - .hostnameVerifier { _, _ -> true } - } catch (e: Exception) { - throw RuntimeException(e) - } \ No newline at end of file