Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49239

Ionic can't make https request calls

$
0
0

VERY SIMPLE QUESTION:
Is it possible to allow requests to servers hosted using self signed certificates?
As far I understood, the problem is the WebView.
Using Java code, I can trust my certificate, but access https inside the WebView I can’t.

MORE EXTENDED QUESTION:
I created an Ionic App that requests to an https server. (it doesn’t work).
And I created an Android Java App that requests the same server. (it works).

The Ionic app code: ionic app
The Java app code: java app

I created a very simple page in an Apache2 server on 192.168.1.27 using SSL (self signed certificate) and CORS enabled.

I created the certificate using:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./server.key -out ./server.crt -addext "subjectAltName = IP.1:192.168.1.27"

In the Ionic app I called:

    this.http.get('https://192.168.1.27:8443').subscribe({
      next: (response) => { console.log(response); },
      error: (error) => { console.error(error); },
      complete: () => console.log('completed!!!!')
    });

I copied the server.crt to res/raw/server.crt in both apps.
I created the file xml/network_security_config.xml
I trusted the certificate, I allowed clear text traffic to 192.168.1.27 in both apps.

Using my Java Android app (on a physical device) the request call works fine.

Using ionic serve in another computer with another IP (192.168.1.2), my app works.

Using my Ionic app on an Android physical device I get this error:

If I open a browser using my Android cellphone, I can navigate to https://192.168.1.27:8443

On BridgeWebViewClient I overrided onReceivedSslError and printed a message to inspect if an ssl error is caught, and yes, I get an ssl error.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>