Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-3576

Add support for interstitial user confirmation of self-signed SSL certs to CordovaWebView and InAppBrowser

    XMLWordPrintableJSON

Details

    Description

      Local https links are blocked by default in InAppBrowser (links using a local SSL certificate which can't be verified by a 3rd party). Ideally, user should be given an option to proceed or cancel the request like the default desktop/mobile browsers do.

      Right now, we have to overwrite the following API in Android to access such URLs but onReceivedSslError() function gets called only for the main PhoneGap window browser and not for InAppBrowser.

      Create a new class:
      public class CustomWebViewClient extends CordovaWebViewClient {

      public static final String LOG_TAG = "Plugin";

      public CustomWebViewClient(DroidGap ctx)

      { super(ctx); Log.d(LOG_TAG, "Constructor!"); }

      @Override
      public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)

      { handler.proceed(); }

      }

      In the main class, we use our custom class as a web view client
      CordovaWebViewClient webViewClient = new CustomWebViewClient(this);
      webViewClient.setWebView(this.appView);
      this.appView.setWebViewClient(webViewClient);

      And similar type of code needs to be written for iOS.

      InAppBrowser should pick up the SSL settings from the main web view and once we overwrite the onReceivedSslError() function, then it should allow such URLs in the InAppBrowser too.

      Attachments

        1. InAppBrowser.java
          35 kB
          Montyleena

        Issue Links

          Activity

            People

              Unassigned Unassigned
              montylee Montyleena
              Votes:
              4 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: