Closed Flyer-Flair closed 2 months ago
I think you should use custom BaseHttpDownloadManager
See more detail
I think you should use custom
BaseHttpDownloadManager
See more detail
I find this class. The mothed of this class is following:
abstract class BaseHttpDownloadManager {
abstract fun download(apkUrl: String, apkName: String): Flow<DownloadStatus>
abstract fun cancel()
abstract fun release()
}
But,I do not know how this class can solve the SSL problem. And, why the following code not work?
private fun trustAllHosts() {
val manager: TrustManager = object : X509TrustManager {
override fun getAcceptedIssuers(): Array<X509Certificate> {
return arrayOf()
}
override fun checkClientTrusted(chain: Array<out X509Certificate>?, authType: String?) {
LogUtil.d(TAG, "checkClientTrusted")
}
override fun checkServerTrusted(chain: Array<out X509Certificate>?, authType: String?) {
LogUtil.d(TAG, "checkServerTrusted")
}
}
try {
val sslContext = SSLContext.getInstance("TLS")
sslContext.init(null, arrayOf(manager), SecureRandom())
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.socketFactory)
} catch (e: Exception) {
LogUtil.e(TAG, "trustAllHosts error: $e")
}
}
I think you should use custom
BaseHttpDownloadManager
See more detailI find this class. The mothed of this class is following:
abstract class BaseHttpDownloadManager { abstract fun download(apkUrl: String, apkName: String): Flow<DownloadStatus> abstract fun cancel() abstract fun release() }
But,I do not know how this class can solve the SSL problem. And, why the following code not work?
private fun trustAllHosts() { val manager: TrustManager = object : X509TrustManager { override fun getAcceptedIssuers(): Array<X509Certificate> { return arrayOf() } override fun checkClientTrusted(chain: Array<out X509Certificate>?, authType: String?) { LogUtil.d(TAG, "checkClientTrusted") } override fun checkServerTrusted(chain: Array<out X509Certificate>?, authType: String?) { LogUtil.d(TAG, "checkServerTrusted") } } try { val sslContext = SSLContext.getInstance("TLS") sslContext.init(null, arrayOf(manager), SecureRandom()) HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.socketFactory) } catch (e: Exception) { LogUtil.e(TAG, "trustAllHosts error: $e") } }
Through BaseHttpDownloadManager
you can download by yourself, such as using OkHttp and solve the problems encountered
appupdate:4.2.3
download error: javax.net.ssl.SSLPeerUnverifiedException: Hostname xxxxxx not verified:
certificate: sha1/67uxxxxxxxxxxx
DN: CN=.xxx.com,O=xxxx公司,L=Wuxi,ST=Jiangsu,C=CN
subjectAltNames: [.xxx.com, xxx.com]
Hostname not verified:
certificate: sha1/67xxxxxxxxxxxxx
DN: CN=.hikwuxi.com,O=xxxxxxxx公司,L=Wuxi,ST=Jiangsu,C=CN
subjectAltNames: [.xxxx.com, xxx.com]
How to resolve? Please!