From 8307daee63373e47e68efcdf86cd0c78d2d5affe Mon Sep 17 00:00:00 2001 From: len Date: Fri, 29 Sep 2017 18:31:18 +0200 Subject: [PATCH] Trust mangahere certificate for now... --- .../source/online/english/Mangahere.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt index 033ef9d6c..88032abda 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt @@ -7,9 +7,13 @@ import okhttp3.HttpUrl import okhttp3.Request import org.jsoup.nodes.Document import org.jsoup.nodes.Element +import java.security.SecureRandom +import java.security.cert.X509Certificate import java.text.ParseException import java.text.SimpleDateFormat import java.util.* +import javax.net.ssl.SSLContext +import javax.net.ssl.X509TrustManager class Mangahere : ParsedHttpSource() { @@ -23,6 +27,26 @@ class Mangahere : ParsedHttpSource() { override val supportsLatest = true + private val trustManager = object : X509TrustManager { + override fun getAcceptedIssuers(): Array { + return emptyArray() + } + + override fun checkClientTrusted(chain: Array, authType: String) { + } + + override fun checkServerTrusted(chain: Array, authType: String) { + } + } + + private val sslContext = SSLContext.getInstance("SSL").apply { + init(null, arrayOf(trustManager), SecureRandom()) + } + + override val client = super.client.newBuilder() + .sslSocketFactory(sslContext.socketFactory, trustManager) + .build() + override fun popularMangaSelector() = "div.directory_list > ul > li" override fun latestUpdatesSelector() = "div.directory_list > ul > li"