PhoneGap的/科尔多瓦在白名单中的跨域SSL请求导出APK后不工作科尔、名单、多瓦、工作

2023-09-04 05:48:26 作者:派大星的海洋裤

我创建了一个PhoneGap的应用程序,它需要使用自签名的SSL服务进行通信。

I have created a phonegap app which needs to communicate with a self signed SSL service.

我在白名单中我的网址在RES / XML / cordova.xml像这样:

I whitelisted my url in res/xml/cordova.xml like so:

<获得原产地=htt​​ps://www.mydomain.com子域=真/>

和这工作得很好,当我运行,并建立从食,但如果我再出口,并签署我的应用程序,并手动安装APK然后应用程序无法与我的web服务进行通信。

and this works fine when I run and build from eclipse but if I then export and sign my app and manually install the APK then the app is unable to communicate with my web service.

与服务器的通信是通过煎茶触摸库,像这样:

The communication with the server is carried out using the Sencha Touch library like so:

Ext.Ajax.request({
        url: 'https://www.mydomain.com',
        method: 'get',          
        success: function(result) {                 
        },
        failure: function(result) {         
        }           
    }); 

pciated任何帮助非常AP $ P $

Any help much appreciated

推荐答案

现在的问题是,你正在使用自签名证书。而Android的WebView不允许默认情况下,自签名的SSL证书。 PhoneGap/Cordova覆盖这在CordovaWebViewClient类但多不偏离其行为;如果应用程序调试签订,将继续并忽略该错误,否则就会失败。

The problem is you are using a self-signed cert. The Android WebView does not allow by default self-signed SSL certs. PhoneGap/Cordova overrides this in the CordovaWebViewClient class but does not deviate its behaviour by much; if the app is debug-signed, it will proceed and ignore the error, otherwise it will fail.

您可以改变上面的链接在应用程序中code,使 onReceivedSslError 方法总是调用 handler.proceed() - 但不建议这样做。不要使用自签名证书!

You could change the above-linked to code in your application and make the onReceivedSslError method always call handler.proceed() - but this isn't recommended. Don't use a self-signed certificate!