Search code examples
androidcordovaphonegap

Security issue with allow-navigation on PhoneGap app - Blank screen


We have just moved servers and our PhoneGap app has stopped working, suddenly showing a blank screen with no explanation. I've tried debugging Android with Chrome dev tools but that whole process seems to be totally broken in 2019 (I can debug webpages fine, the app just does not appear in the list no matter what I try).

Our app's index.html simply redirects to a url on our server. It was working fine yesterday. We did not change the domain or app url and everything works totally fine in the browser.

Is there a DNS cache on PhoneGap or something with the page headers conflicting with PhoneGap perhaps?

In config.xml we have these settings:

<allow-navigation href="https://www.example.com/*" />
<plugin name="cordova-plugin-whitelist" spec="1.3.3" />
<plugin name="cordova-plugin-inappbrowser" spec="3.0.0" />
<access origin="*" />

Update:

I tried using a plain text file as the app homepage in config.xml and it still doesn't work. The whole domain seems to be blocked despite the allow-navigation rule I posted above.

<content src="https://www.example.com/test.txt" /> //DOES NOT WORK
<content src="https://www.youtube.com/" />         //WORKS FINE

Solution

  • This issue was caused by a missing OpenSSL cert on the new server. PHP 7 requires an SSL cert for use with certain requests. More info here. For some reason, the Cordova app was detecting the missing cert and blocking the app from loading. We were fixing the PHP cert to solve another issue and it happily solved this one too!

    You can also fix the blank screen issue or workaround it temporarily by building your app without a certificate. In PhoneGap Build, choose "no key selected" from the dropdown before building. Note however, the Play store wont accept apps built without a cert.