简体   繁体   English

Android Hybrid App:JQueryMobile ajax不适用于https,但适用于http

[英]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]. 我们有一个基于JQueryMobile的混合android应用[将所有JS / CSS / HTML打包在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. 此应用程序可以使用JQM ajax调用[用于http url]从服务器[通过RESTful接口]从服务器获取json数据,但是当我们尝试使用https进行相同操作时,它将失败。

Another bit is: We have used bouncycastle based certificate to enable TLS [on server] which is working fine with native android calls [using java]. 另一个要点是:我们已经使用基于充气弹跳的证书来启用TLS(在服务器上),该TLS与本机android调用(使用java)一起正常工作。

Now we are confused as to why it is working with http however not with https. 现在,我们对为什么它可以与http而不是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. 我们认为这与CORS / XOR问题无关,因为我们的Ajax http调用工作正常。

I'm assuming you're using the Android WebView class? 我假设您正在使用Android WebView类? 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(); 如果可以接受的错误,则将Log.d行替换为handler.proceed handler.proceed(); ;。 (with an if condition to verify that it's the same error). (带有if条件,以验证它是否是相同的错误)。 Ideally, you'd correct whatever issue is causing it however. 理想情况下,您应该纠正引起问题的任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM