Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-4488

Android: Expose WebView onReceivedSslError

    Details

      Description

      Feature

      Expose the onReceivedSslError method of the web view on Android so that developers can handle what happens when an SSL certificate is rejected.

      Why

      The default behavior is to reject any SSL certificate that doesn't validate. By exposing this, the developer could ask the user if they want to proceed.

      Sample Code

      The following could utilize this feature. I bet there's a better way to expose the SSLError constants.

      app.js

      var window = Ti.UI.createWindow({
          backgroundColor:'#fff'
      });
       
      var webView = Ti.UI.createScrollView({
          width: 320, height: 480,
          contentWidth: 2000
      });
      webView.addEventListener('onReceivedSslError', function(evt) {
          // What error happened? Check the constants. These are taken from the following URL:
          // http://developer.android.com/reference/android/net/http/SslError.html
          switch (evt.error) {
              case evt.SSL_EXPIRED:
                  break;
              case evt.SSL_IDMISMATCH:
                  break;
              case evt.SSL_MAX_ERROR:
                  break;
              case evt.SSL_NOTYETVALID:
                  break;
              case evt.SSL_UNTRUSTED:
                  break;
          }
          // Should we proceed?
          evt.handler.proceed();
      });
      window.add(webView);
       
      window.open();
      

      Relevant Documentation

      http://developer.android.com/reference/android/webkit/WebViewClient.html#onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError)

      Associated Helpdesk Ticket

      http://appc.me/c/APP-235542

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sunila Sunila
                Reporter:
                dtoth Dawson Toth
                Reviewer:
                Hieu Pham
              • Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Source Code