|
|
@ -20,15 +20,19 @@ object SSLHelper { |
|
|
|
* 网络上大部分的解决方案都是让客户端不对证书做任何检查, |
|
|
|
* 网络上大部分的解决方案都是让客户端不对证书做任何检查, |
|
|
|
* 这是一种有很大安全漏洞的办法 |
|
|
|
* 这是一种有很大安全漏洞的办法 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
val unsafeTrustManager: X509TrustManager = object : X509TrustManager { |
|
|
|
val unsafeTrustManager: X509TrustManager = |
|
|
|
|
|
|
|
@SuppressLint("CustomX509TrustManager") |
|
|
|
|
|
|
|
object : X509TrustManager { |
|
|
|
@SuppressLint("TrustAllX509TrustManager") |
|
|
|
@SuppressLint("TrustAllX509TrustManager") |
|
|
|
@Throws(CertificateException::class) |
|
|
|
@Throws(CertificateException::class) |
|
|
|
override fun checkClientTrusted(chain: Array<X509Certificate>, authType: String) { |
|
|
|
override fun checkClientTrusted(chain: Array<X509Certificate>, authType: String) { |
|
|
|
|
|
|
|
//do nothing,接受任意客户端证书 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("TrustAllX509TrustManager") |
|
|
|
@SuppressLint("TrustAllX509TrustManager") |
|
|
|
@Throws(CertificateException::class) |
|
|
|
@Throws(CertificateException::class) |
|
|
|
override fun checkServerTrusted(chain: Array<X509Certificate>, authType: String) { |
|
|
|
override fun checkServerTrusted(chain: Array<X509Certificate>, authType: String) { |
|
|
|
|
|
|
|
//do nothing,接受任意客户端证书 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun getAcceptedIssuers(): Array<X509Certificate> { |
|
|
|
override fun getAcceptedIssuers(): Array<X509Certificate> { |
|
|
|