Dinesh Dinesh - 1 month ago 22
Android Question

in cordova/on android app requests with https fail but same request using http succeed

I have a backend server that is accessible on two ports - one with HTTP and another with HTTPS. It uses a self-signed certificate.

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)


I wonder how to proceed. Do I need to register the self-signed certificate somewhere in config, or something else?

Thanks a lot.

Answer

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.

Open “\cordova\platforms\android\CordovaLib\src\org\apache\cordova\ CordovaWebViewClient.java”. In 'onReceivedSslError' method, comment the else part and add handler.proceed() instead.