ArgosComics: Ignore ssl errors (#4844)

ignore ssl
This commit is contained in:
bapeey 2024-08-30 06:17:57 -05:00 committed by Draff
parent 4e3f2d235f
commit f6bf98b764
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 28 additions and 1 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.ArgosComics' extClass = '.ArgosComics'
themePkg = 'madara' themePkg = 'madara'
baseUrl = 'https://argoscomic.com' baseUrl = 'https://argoscomic.com'
overrideVersionCode = 4 overrideVersionCode = 5
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -1,11 +1,18 @@
package eu.kanade.tachiyomi.extension.pt.argoscomics package eu.kanade.tachiyomi.extension.pt.argoscomics
import android.annotation.SuppressLint
import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.network.interceptor.rateLimit
import okhttp3.MediaType.Companion.toMediaType import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.ResponseBody.Companion.toResponseBody import okhttp3.ResponseBody.Companion.toResponseBody
import java.security.SecureRandom
import java.security.cert.X509Certificate
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager
class ArgosComics : Madara( class ArgosComics : Madara(
"Argos Comics", "Argos Comics",
@ -13,8 +20,28 @@ class ArgosComics : Madara(
"pt-BR", "pt-BR",
SimpleDateFormat("MMM dd, yyyy", Locale("pt", "BR")), SimpleDateFormat("MMM dd, yyyy", Locale("pt", "BR")),
) { ) {
private fun OkHttpClient.Builder.ignoreAllSSLErrors(): OkHttpClient.Builder {
val naiveTrustManager = @SuppressLint("CustomX509TrustManager")
object : X509TrustManager {
override fun getAcceptedIssuers(): Array<X509Certificate> = emptyArray()
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
}
override val client = super.client.newBuilder() override val client = super.client.newBuilder()
.rateLimit(3) .rateLimit(3)
.ignoreAllSSLErrors()
.addInterceptor { chain -> .addInterceptor { chain ->
val response = chain.proceed(chain.request()) val response = chain.proceed(chain.request())
val mime = response.headers["Content-Type"] val mime = response.headers["Content-Type"]