4

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.

Dinesh
  • 4,437
  • 5
  • 40
  • 77

1 Answers1

4

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.

SnapADragon
  • 536
  • 7
  • 21
  • 3
    Just in case, I'm using Ionic and the file I had to change was: **platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java**. – andres.arslanian Apr 30 '16 at 18:59
  • I can't get it to work with https. I don't have an SSL certificate. Do I have to get one to make a request to a server in debug mode? Can't I do a request using http without the ssl certificate? – Inês Borges Dec 28 '22 at 14:11