Search code examples
javascriptandroidajaxjquery-mobilebouncycastle

Android Hybrid App : JQueryMobile ajax is not working with https but works with http


We have a hybrid android app based on JQueryMobile [with all JS/CSS/HTML packaged inside APK]. This app is able to fetch json data from server [with RESTful interface] using JQM ajax call [for http url] however when we are trying to do the same thing using https it fails.

Another bit is: We have used bouncycastle based certificate to enable TLS [on server] which is working fine with native android calls [using java].

Now we are confused as to why it is working with http however not with https. Any hint in this regard will be appreciated. We don't think it is something to do with CORS/XOR problem as our ajax http calls are working fine.


Solution

  • I'm assuming you're using the Android WebView class? If so, check what the error is by implementing this method:

     webView.setWebViewClient(new WebViewClient() {
     public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
         Log.d("ssl_error", "The error is: " + error);
     }
    

    With that code, you can see what error, if any, is causing the blank page. If it's an error that you can accept, then replace the Log.d line with handler.proceed(); (with an if condition to verify that it's the same error). Ideally, you'd correct whatever issue is causing it however.