I know that SSL handler.proceed() is not allowed on the playstore. And they reject the app once their bots able to find the same in the uploaded app. For testing purpose I was asked to share the UAT APK with this SSL bypass only for UAT environment. When I am trying to use handler.proceed(), I get a blank screen with below error
Ignoring unexpected ssl error proceed callback
in the logcat. I have searched the whole internet and I found nothing useful yet. Below is my code.
override fun onReceivedSslError(view: WebView?, handler: SslErrorHandler, er: SslError?) {
super.onReceivedSslError(view, handler, er)
LogHelper.e("check error", "onReceivedError")
showErrorDialog(handler, er)
}
private fun showErrorDialog(handler: SslErrorHandler, error: SslError?) {
val builder = activity?.let { AlertDialog.Builder(it) }
var message = "SSL Certificate error."
when (error?.primaryError) {
SslError.SSL_UNTRUSTED -> message = "The certificate authority is not trusted."
SslError.SSL_EXPIRED -> message = "The certificate has expired."
SslError.SSL_IDMISMATCH -> message = "The certificate Hostname mismatch."
SslError.SSL_NOTYETVALID -> message = "The certificate is not yet valid."
}
message += " Do you want to continue anyway?"
builder?.setTitle("SSL Certificate Error");
builder?.setMessage(message)
builder?.setPositiveButton(activity?.getString(R.string.button_continue)) { dialog, _ ->
dialog.dismiss()
handler.proceed()
}
builder?.setNegativeButton(activity?.getString(R.string.cancel)) { _, _ ->
handler.cancel()
activity?.onBackPressed()
}
builder?.create()?.show()
}
Below is the solution. No need to call the
super.onReceivedSslError(view, handler, er)as we need handle this on our side only. Although this does not prevent your app from playstore rejection.