From fcb6b85924f08cae656c20664996ca311baa8904 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 22 Aug 2021 13:54:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/http/SSLHelper.kt | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/http/SSLHelper.kt b/app/src/main/java/io/legado/app/help/http/SSLHelper.kt index b0bd53484..81e9c74f7 100644 --- a/app/src/main/java/io/legado/app/help/http/SSLHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/SSLHelper.kt @@ -20,21 +20,25 @@ object SSLHelper { * 网络上大部分的解决方案都是让客户端不对证书做任何检查, * 这是一种有很大安全漏洞的办法 */ - val unsafeTrustManager: X509TrustManager = object : X509TrustManager { - @SuppressLint("TrustAllX509TrustManager") - @Throws(CertificateException::class) - override fun checkClientTrusted(chain: Array, authType: String) { - } + val unsafeTrustManager: X509TrustManager = + @SuppressLint("CustomX509TrustManager") + object : X509TrustManager { + @SuppressLint("TrustAllX509TrustManager") + @Throws(CertificateException::class) + override fun checkClientTrusted(chain: Array, authType: String) { + //do nothing,接受任意客户端证书 + } - @SuppressLint("TrustAllX509TrustManager") - @Throws(CertificateException::class) - override fun checkServerTrusted(chain: Array, authType: String) { - } + @SuppressLint("TrustAllX509TrustManager") + @Throws(CertificateException::class) + override fun checkServerTrusted(chain: Array, authType: String) { + //do nothing,接受任意客户端证书 + } - override fun getAcceptedIssuers(): Array { - return arrayOf() + override fun getAcceptedIssuers(): Array { + return arrayOf() + } } - } val unsafeSSLSocketFactory: SSLSocketFactory by lazy { try {