Capacitor Android app do Javascript rest calls to Nginx server with self-signed certificate

Hello everyone,

I’m trying to access an rest server running nginx (using axios) with a self-signed certificate (for development purposes).
It’s working from within the browser, but failing when running on Android. It just returns an Request aborted without any information:

chunk-vendors.fa7cefd0.js:1 Uncaught (in promise) Error: Request aborted
    at t.exports (chunk-vendors.fa7cefd0.js:1)
    at XMLHttpRequest.v.onabort (chunk-vendors.fa7cefd0.js:33)

Online I’ve read that this is caused by invalid certificates. Things I’ve done to resolve:

  1. Went to the browser (on my phone) and accepted the security risk from this unknown certificate.
  2. Installed .p12 file on my phone (as app certificate) that i’ve created using my .crt and .key file

I still get the aborted error

So I decided to use native http calls ignoring ssl certificates all together, however my app now use javascript library hls.js to stream livevideo. This library offcourse doesn’t use native HTTP calls.

So I need to tackle the root issue, but I don’t know what that is and how to resolve.

Anyone who has experience with certificates, openssl, android, capacitor and nginx all together? Any help is appreciated.

Self-signed certificates are a massive PITA. Can you just get a real one from someplace like LetsEncrypt instead?

2 Likes

I would agree with @rapropos here. LetsEncrypt is free and provides a valid cert.

@rapropos @mhartington It’s what the client wants, and it’s for a dev server, at this moment. But I agree with both of you. Thanks for the suggestion