mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fixed akwam
This commit is contained in:
parent
1804484860
commit
5596408670
1 changed files with 29 additions and 4 deletions
|
@ -1,13 +1,11 @@
|
||||||
package com.lagradost.cloudstream3.network
|
package com.lagradost.cloudstream3.network
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
import com.fasterxml.jackson.module.kotlin.readValue
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.USER_AGENT
|
|
||||||
import com.lagradost.cloudstream3.app
|
|
||||||
import com.lagradost.cloudstream3.mapper
|
|
||||||
import kotlinx.coroutines.CancellableContinuation
|
import kotlinx.coroutines.CancellableContinuation
|
||||||
import kotlinx.coroutines.CompletionHandler
|
import kotlinx.coroutines.CompletionHandler
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
|
@ -19,7 +17,12 @@ import org.jsoup.nodes.Document
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
import java.security.SecureRandom
|
||||||
|
import java.security.cert.X509Certificate
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
import javax.net.ssl.SSLContext
|
||||||
|
import javax.net.ssl.TrustManager
|
||||||
|
import javax.net.ssl.X509TrustManager
|
||||||
import kotlin.coroutines.resumeWithException
|
import kotlin.coroutines.resumeWithException
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,6 +215,27 @@ fun putRequestCreator(
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/59322754
|
||||||
|
// Issues with Akwam otherwise
|
||||||
|
fun OkHttpClient.Builder.ignoreAllSSLErrors(): OkHttpClient.Builder {
|
||||||
|
val naiveTrustManager = @SuppressLint("CustomX509TrustManager")
|
||||||
|
object : X509TrustManager {
|
||||||
|
override fun getAcceptedIssuers(): Array<X509Certificate> = arrayOf()
|
||||||
|
override fun checkClientTrusted(certs: Array<X509Certificate>, authType: String) = Unit
|
||||||
|
override fun checkServerTrusted(certs: Array<X509Certificate>, authType: String) = Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
val insecureSocketFactory = SSLContext.getInstance("TLSv1.2").apply {
|
||||||
|
val trustAllCerts = arrayOf<TrustManager>(naiveTrustManager)
|
||||||
|
init(null, trustAllCerts, SecureRandom())
|
||||||
|
}.socketFactory
|
||||||
|
|
||||||
|
sslSocketFactory(insecureSocketFactory, naiveTrustManager)
|
||||||
|
hostnameVerifier { _, _ -> true }
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
open class Requests {
|
open class Requests {
|
||||||
var baseClient = OkHttpClient()
|
var baseClient = OkHttpClient()
|
||||||
|
|
||||||
|
@ -221,6 +245,7 @@ open class Requests {
|
||||||
baseClient = OkHttpClient.Builder()
|
baseClient = OkHttpClient.Builder()
|
||||||
.followRedirects(true)
|
.followRedirects(true)
|
||||||
.followSslRedirects(true)
|
.followSslRedirects(true)
|
||||||
|
.ignoreAllSSLErrors()
|
||||||
.cache(
|
.cache(
|
||||||
// Note that you need to add a ResponseInterceptor to make this 100% active.
|
// Note that you need to add a ResponseInterceptor to make this 100% active.
|
||||||
// The server response dictates if and when stuff should be cached.
|
// The server response dictates if and when stuff should be cached.
|
||||||
|
|
Loading…
Reference in a new issue