1、問題
個別手機用OkDownload下載Bilibili網址視頻的時候下載失敗,但是大部分手機下載沒問題。
在繼承的DownloadListener4WithSpeed類的重寫taskEnd函數里面。
override fun taskEnd(task: DownloadTask, cause: EndCause, realCause: Exception?, taskSpeed: SpeedCalculator) {L.e("DownloadListenerWithSpeed taskEnd >> "+ task.info?.filename +" / "+ task.info?.totalLength + " : "+task.info?.totalOffset + " Exception = "+realCause)
}
錯誤關鍵日志如下
DownloadListenerWithSpeed taskEnd >> 340439077-1-16(2).mp4 / 0 : 0 Exception = javax.net.ssl.SSLHandshakeException: Chain validation failed
2、分析
看到SSLHandshakeException異常,我們立馬就想到忽略證書,然后在下載功能前面加上如下代碼,CertUtil.handleSSLHandshake()
public class CertUtil {/*** 忽略https的證書校驗* 避免Glide加載https圖片報錯:* javax.n