You need to update the WebViewClient handler as described below. If you haven’t used webview with onReceivedSslError () in your application, check if you are using the latest SDK to update the version in accordance with the new Google security policy.
To properly handle the SSL certificate, change your code to call SslErrorHandler.proceed () when the certificate provided by the server meets your expectations and otherwise calls SslErrorHandler.cancel ().
For example, I am adding a warning dialog box that the user has confirmed and it appears that Google no longer displays the warning.
@Override public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); String message = "SSL Certificate error."; switch (error.getPrimaryError()) { case SslError.SSL_UNTRUSTED: message = "The certificate authority is not trusted."; break; case SslError.SSL_EXPIRED: message = "The certificate has expired."; break; case SslError.SSL_IDMISMATCH: message = "The certificate Hostname mismatch."; break; case SslError.SSL_NOTYETVALID: message = "The certificate is not yet valid."; break; } message += " Do you want to continue anyway?"; builder.setTitle("SSL Certificate Error"); builder.setMessage(message); builder.setPositiveButton("continue", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.proceed(); } }); builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.show(); }
After this change, no warnings will be displayed.
Anant shah
source share