问题描述
我有一个可以在两个端口上访问的后端服务器-一个使用HTTP,另一个使用HTTPS.它使用自签名证书.
I have a backend server that is accessible on two ports - one with HTTP and another with HTTPS. It uses a self-signed certificate.
当我使用HTTP请求运行时,从我的ionic/cordova混合应用程序中获得了成功.在首次请求期间,我还提供了基本授权.但是,使用HTTPS时,完全相同的请求将失败.例如
From my ionic/cordova hybrid app when I run using HTTP requests they all succeed. During first request I also include a basic authorization. However, the exact same requests fail when using HTTPS. For example
http://10.1.2.3:8000/hello.js <<< works like a charm
https://10.1.2.3:8100/hello.js <<<< this fails (but works in android browser after a warning page)
我想知道如何进行.我是否需要在config或其他地方注册自签名证书?
I wonder how to proceed. Do I need to register the self-signed certificate somewhere in config, or something else?
非常感谢.
推荐答案
我想知道您是否找到答案,但仍然想为寻求解决方案的其他人发布答案:Cordova不允许对服务器的https调用上面安装了不受信任的ssl证书.您可以忽略此错误,并通过在cordova文件中进行一些小的更改来继续操作.
I wonder if you have found your answer or not, but still want to post answer for others looking for the solution: Cordova doesn't allow https calls to Servers with untrusted ssl certificate installed on them. You can ignore this error and continue by making a small change in a cordova file.
打开"\ cordova \ platforms \ android \ CordovaLib \ src \ org \ apache \ cordova \ CordovaWebViewClient.java".在"onReceivedSslError"方法中,注释else部分,然后添加handler.proceed().
这篇关于在cordova/上使用https的android应用程序请求失败,但使用http的相同请求成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!