What is the alternate for onReceivedSslError() in Webview?

1.2k views Asked by At

I am working on app that will connect user with available open WIFIs by providing their landing pages (having login option) in the app. Google is showing alert for using onReceivedSslError() in WebView for loading Wifi's landing page in the app.

If I remove this method then link will not work. In order to make it functional I need to add the domain name in the network_security_config.xml file but I do not know which link will be shown by wifi's vendors as it is not in my control. This insist me to use onReceivedSslError() method in Webview. I am showing alert dialog inside onReceivedSslError() to ask user if he wants to continue or not.

 AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("SSL Certificate Verification!\nPlease click on CONTINUE to open login 
page of selected Wifi");
        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();
                finish();
            }
        });
        final AlertDialog dialog = builder.create();
        dialog.show();` 

Error getting inside onReceivedSslError()

error.getPrimaryError() : 3 SSL_UNTRUSTED

I have tried this too https://www.rgagnon.com/javadetails/java-fix-certificate-problem-in-HTTPS.html but again not working .

Any available link is not solving my issue. Kindly guide me. Thanks in advance

0

There are 0 answers