WebView SSL 错误处理
修复帮助
https://support.google.com/faqs/answer/7071387
原因
onReceivedSslError 中没有做 ssl 错误校验便直接 调用方法handler?.proceed()
解决方案
override fun onReceivedSslError(
view: WebView?,
handler: SslErrorHandler?,
error: SslError?
) {
val url = view?.url ?: ""
if (url.isEmpty()) {
handler?.cancel()
return
}
val host = Uri.parse(url).host ?: ""
if (host.contains("test.com")) {
handler?.proceed()
return
}
var builder = AlertDialog.Builder(view?.context)
var message = when (error?.primaryError) {
SslError.SSL_UNTRUSTED -> {
}
SslError.SSL_EXPIRE