HackTricks
Search…
Pentesting
Powered By GitBook
Make APK Accept CA Certificate
Some applications don't like user downloaded certificates, so in order to inspect web traffic for some apps we actually have to decompile the application & add a few things & recompile it.

Automatic

The tool https://github.com/shroudedcode/apk-mitm will automatically make the necessary changes to the application to start capturing the requests and will also disable certificate pinning (if any).

Manual

First we decompile the app: apktool d *file-name*.apk
Then we go into the Manifest.xml file & scroll down to the <\application android> tag & we are going to add the following line if it isn't already there:
android:networkSecurityConfig="@xml/network_security_config
Before adding:
After adding:
Now go into the res/xml folder & create/modify a file named network_security_config.xml with the following contents:
1
<network-security-config>
2
<base-config>
3
<trust-anchors>
4
<!-- Trust preinstalled CAs -->
5
<certificates src="system" />
6
<!-- Additionally trust user added CAs -->
7
<certificates src="user" />
8
</trust-anchors>
9
</base-config>
10
</network-security-config>
Copied!
Then save the file & back out of all the directories & rebuild the apk with the following command: apktool b *folder-name/* -o *output-file.apk*
Last modified 1yr ago
Copy link