PhoneGap的/科尔多瓦在白名单中的跨域SSL请求导出APK后不工作 [英] Phonegap/Cordova whitelisted cross domain SSL request not working after exporting APK
问题描述
我创建了一个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:
<获得原产地=https://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证书。 <一href="https://github.com/apache/incubator-cordova-android/blob/master/framework/src/org/apache/cordova/CordovaWebViewClient.java#L279-298">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!
这篇关于PhoneGap的/科尔多瓦在白名单中的跨域SSL请求导出APK后不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!