Skip to content
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

Updated AndroidManifest.xml to trust user installed CA certificate #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

drkhn1234
Copy link

As you may know later Android 7, Android SDK makes apps trust only CA certificates contained within system certificate store. It can be overrided so that applications can also trust user installed certificates (https://developer.android.com/training/articles/security-config#TrustingAdditionalCas). I saw that PowerTunnel already has an xml file in res/xml/ but it is not attributed in AndroidManifest.xml file hence I fixed it.

As you may know later Android 7, Android SDK makes apps trust only CA certificates contained within system certificate store. It can be overrided so that applications can also trust user installed certificates (https://developer.android.com/training/articles/security-config#TrustingAdditionalCas). I saw that PowerTunnel already has an xml file in res/xml/ but it is not attributed in AndroidManifest.xml file hence I fixed it.
@krlvm
Copy link
Owner

krlvm commented Jun 7, 2022

As far as I understand, specifying the Network Security Config will allow the application to trust all the certificates listed in the configuration - but there are no additional certificates other than those set in the system or user space, which are already trusted by default. Or am I missing something?

@drkhn1234
Copy link
Author

drkhn1234 commented Jun 8, 2022

As far as I understand, specifying the Network Security Config will allow the application to trust all the certificates listed in the configuration - but there are no additional certificates other than those set in the system or user space, which are already trusted by default. Or am I missing something?

Sorry if I mess up with technical details as I've just researched on this topic due to some specific issue, so maybe it is more adequate for me to tell it first.

I was trying to use proxy mode on the app but the app prompts you to install Power tunnel root CA to function properly, now, afaik this is due to proxy utilizing some kind of encrypted connection (via TLS??) with host hence it needs a root CA authority within the system so it can authorize itself (actuate handshake protocol) for host to be able to connect to proxy.

After this, proxy modifies the host's request that will be forwarded to actual website user wants to reach. At this stage proxy can do stuff such as using a custom DNS, DoH, SNI modifications, and other actions to circumvent Deep Packet Inspection system of ISP.


Now onto my PR, so far as I know Android used to allow applications to accept user installed CA certificates prior to Android 7 and its corresponding API level, but as PowerTunnel builds upon Android API level 30 it is by default not accepting user installed CA certificates (by default apps only trust system default CA certificates) which interrupts the intended function of the app. Luckily there is a way to specify in Android Manifest.xml to app that it should also trust user installed CA certificates.

I haven't dug deep down the options to adjust Network_Security_Config.xml, nonetheless, afaik the current file in place allows for PowerTunnel to accept User installed CA certificates—it just needs to be manifested in Android manifest to take effect.

@drkhn1234 drkhn1234 closed this Jun 8, 2022
@drkhn1234 drkhn1234 reopened this Jun 8, 2022
@krlvm
Copy link
Owner

krlvm commented Jun 8, 2022

I was trying to use proxy mode on the app but the app prompts you to install Power tunnel root CA to function properly, now, afaik this is due to proxy utilizing some kind of encrypted connection (via TLS??) with host hence it needs a root CA authority within the system so it can authorize itself (actuate handshake protocol) for host to be able to connect to proxy.

I think you have enabled some functionality that needs MITM, e.g. SNI Modification, - the certificate installation is needed to decrypt and re-encrypt the traffic. Or there are other problems with installing the certificate on Android 11+?

@drkhn1234
Copy link
Author

drkhn1234 commented Jun 8, 2022

I was trying to use proxy mode on the app but the app prompts you to install Power tunnel root CA to function properly, now, afaik this is due to proxy utilizing some kind of encrypted connection (via TLS??) with host hence it needs a root CA authority within the system so it can authorize itself (actuate handshake protocol) for host to be able to connect to proxy.

I think you have enabled some functionality that needs MITM, e.g. SNI Modification, - the certificate installation is needed to decrypt and re-encrypt the traffic. Or there are other problems with installing the certificate on Android 11+?

You are right, what causes root CA installation dialog was indeed SNI modifications. I am not totally sure if there is really a genuine problem with installation of certificates, but in my experience despite I checked the user CA certificate store and confirmed that the root CA certificate file PowerTunnel provides was installed successfully, yet, the app never stops to present the same warning dialog which insists the user to install root CA Certificate even though it is already installed; therefore this made me question whether app detects and is able to take advantage of the CA certificates installed by the user and it came to this point where I suspect it is because of the restrictions AOSP made with Android 7 and the AndroidManifest.xml file of the app that didn't linked to network_security_config.xml

@krlvm
Copy link
Owner

krlvm commented Jun 8, 2022

Thanks for the research, it seems indeed I remember the issue where it asks to install a certificate despite already having it installed on Android 11+. Does adding Network Security Config fix this issue?

@drkhn1234
Copy link
Author

Thanks for the research, it seems indeed I remember the issue where it asks to install a certificate despite already having it installed on Android 11+. Does adding Network Security Config fix this issue?

The day I created this PR I tried compiling the program but had some issues with the build environment and it was late at night, had some other work to do, so I haven't been able to deal with it

@krlvm
Copy link
Owner

krlvm commented Jun 8, 2022

Thanks, I'll wait for a replay.
Tell me if you have problems building the project because of my crutches.

@chronos1970
Copy link

I would like to additionally note that for me, even after installing the CA on Android 11 successfully, browsers still throw certificate errors and refuse connection. I have enabled "Use third party CA certificates" on Firefox and it worked with my other CA. I suspect that the CA generated by PowerTunnel might be missing some flags that are required by later versions of Android. The working CA I tested was created using mkcert.

@theonlyfoxy
Copy link

@krlvm I have the same issue with Android 12. After installing CA, The app doesn't detect it also websites seems to throw certificate error and refuse the connection.

Repository owner deleted a comment from theonlyfoxy Dec 25, 2022
@krlvm
Copy link
Owner

krlvm commented Dec 25, 2022

@theonlyfoxy I'm sorry I've sent a wrong file accidentally, try this, please:
app-release.zip

@theonlyfoxy
Copy link

@theonlyfoxy I'm sorry I've sent a wrong file accidentally, try this, please: app-release.zip

Still the same issue is happening.

@krlvm
Copy link
Owner

krlvm commented Dec 25, 2022

So this PR won't fix this I'm afraid :(

@theonlyfoxy
Copy link

So this PR won't fix this I'm afraid :(

So could you work on a fix?

@krlvm
Copy link
Owner

krlvm commented Dec 26, 2022

I'll see what I can do about it, at the moment I don't have Android 11+ devices where this problem occurs (well, there are, but I don't want to update them to Android 11).

@theonlyfoxy
Copy link

I'll see what I can do about it, at the moment I don't have Android 11+ devices where this problem occurs (well, there are, but I don't want to update them to Android 11).

Well you could try on Android 12 Virtual Machine.

@shitcod3r
Copy link

@krlvm the same issue on Android 13. After installing the CA cert, PowerTunnel keeps showing the dialog saying to install CA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants