-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net::ERR_CLEARTEXT_NOT_PERMITTED on Android #20
Comments
I just ran into this. I didn't want to allow http for the entire app, so here is my fix if it helps others:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.worldspinner.portraits">
<application
. . .
android:networkSecurityConfig="@xml/network_security_config">
. . .
</application>
. . .
</manifest>
|
There may be a way to trust a self-signed localhost certificate, but it looks like a pain and potentially impacts the security of the whole app: https://stackoverflow.com/questions/8693991/java-ignore-expired-ssl-certificate/8694377#8694377. Edit: also https://stackoverflow.com/a/21936109/502846 I think users of this plugin will just have to use the configuration you have provided @axis7818 , I will update the docs soon. |
This issue has possibly reoccurred on at least one device - all I see in the log is "TypeError: Failed to fetch" so it may be a different issue. Chrome Mobile WebView 66.0.3359 |
I was able to reproduce the With live reload an What happens in the app is the splash screen doesn't hide. If I background the app and then bring it back into the foreground, the splash screen hides and you can see the error message. If you add a It appears that Capacitor live reload automatically adds For us live reload working well on Android is important not only for the shortened feedback loop for front-end changes but also because that's our workaround for getting TypeScript source maps working with the Chrome dev tools during remote WebView debugging. |
@KevinKelchen Do you see then Is there a way to further configure the |
Thank you for responding! 😀
When I described the As mentioned above, this is because the presence of a
I think you might be able to with <base-config cleartextTrafficPermitted="true">. However, we wouldn't want that in a production/release build while we would want the It'd be more preferable if it was tied to just a live reload scenario like if the Ionic CLI could add the IP to the existing |
I like the last suggestion, as it is possible the user has configured a network_security_config for other purposes than BlobWriter.
That's odd, because I use HMR all the time, though not via the Ionic CLI command. Perhaps this is different to Live Reload? I just set |
Thank you for the crazy-fast reply! 😀
Interesting. I would think if the Android WebView's |
Thanks for the reply and for trying that out and sharing the information! Huh--interesting. If you haven't checked, I suppose it's possible that the final/built version of the It's also possible that your front-end dev server/tooling is configured differently somehow. I'm using the Ionic CLI which calls into the Angular CLI, FWIW. |
Hmm no sign of `usesCleartextTraffic` in the merged manifest. I use Vue CLI for my HMR. I can only assume Ionic CLI is doing some proxying and it's going wrong there?
… On 4 Feb 2021, at 12:06 pm, Kevin Kelchen ***@***.***> wrote:
Thanks for the reply and for trying that out and sharing the information!
Huh--interesting. If you haven't checked, I suppose it's possible that the final/built version of the AndroidManifest.xml could have somehow gotten android:usesCleartextTraffic added to it. To check, open the app's AndroidManifest.xml and then click the Merged Manifest button/tab.
It's also possible that your front-end dev server/tooling is configured differently somehow. I'm using the Ionic CLI which calls into the Angular CLI, FWIW.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub <#20 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AACLZQE6VZXKMGO5TN6LCGLS5IBZVANCNFSM4PXH7EUQ>.
|
I just ran into Kevin's issue. I have no idea why it only started happening now. It does appear that BlobWriter's network security config breaks Capacitor's live reload (as the network address of the web server is not listed as a |
Specifying only 'localhost' in a network security config will break the webview when the app is loaded over the local network via HTTP. A simple, if rather brutish, alternative is to allow cleartext on all domains. close #20
Glad at least that I'm not the only one who bumped into this issue, @diachedelic! 😅 Do you think there might security concerns by allowing cleartext traffic to all domains? FWIW, due to potential security concerns, I will describe the workaround we used in our app. It's basically what I described above:
It's hard to believe it's been over a year since that comment, but so far we've had no issues with our workaround. Workaround
Final thoughtsIf this workaround doesn't become the official recommended configuration, that's probably ok. I at least wanted to provide the workaround as an option for anyone who might be leery of allowing cleartext traffic to all domains. 🙂 Thanks for all that you do to maintain this awesome and much-needed plugin, @diachedelic! 😀 |
Manifests as a "TypeError: Failed to fetch" during
writeFile
.See https://stackoverflow.com/questions/54752716/why-am-i-seeing-neterr-cleartext-not-permitted-errors-after-upgrading-to-cordo
Breaks BlobWriter for many, many Android devices (especially newer ones).
The text was updated successfully, but these errors were encountered: