# Make APK Accept CA Certificate

<details>

<summary><strong>从零开始学习AWS黑客技术，成为</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

**Try Hard Security Group**

<figure><img src="/files/Kw46fTSYxPIOMyKySfL5" alt=""><figcaption></figcaption></figure>

{% embed url="<https://discord.gg/tryhardsecurity>" %}

***

有些应用程序不喜欢用户下载的证书，因此为了检查某些应用程序的Web流量，我们实际上必须反编译该应用程序并添加一些内容，然后重新编译它。

## 自动化

工具[**https://github.com/shroudedcode/apk-mitm**](https://github.com/shroudedcode/apk-mitm)将**自动**对应用程序进行必要的更改以开始捕获请求，并且还会禁用证书固定（如果有）。

## 手动

首先我们反编译应用程序：`apktool d *file-name*.apk`

![](/files/6o039iCWyv5ek6gPNsq8)

然后我们进入**Manifest.xml**文件并滚动到`<\application android>`标签，如果尚未存在，我们将添加以下行：

`android:networkSecurityConfig="@xml/network_security_config`

添加前：

![](/files/AHbVj9o4xoqOlI0EME6v)

添加后：

![](/files/KgFx6nWSagjHHrk8Uttx)

现在进入**res/xml**文件夹，并创建/修改一个名为network\_security\_config.xml的文件，内容如下：

```markup
<network-security-config>
<base-config>
<trust-anchors>
<!-- Trust preinstalled CAs -->
<certificates src="system" />
<!-- Additionally trust user added CAs -->
<certificates src="user" />
</trust-anchors>
</base-config>
</network-security-config>
```

然后保存文件并退出所有目录，使用以下命令重新构建apk：`apktool b *folder-name/* -o *output-file.apk*`

![](/files/RPfveDVcfrX8dd3q80iR)

最后，您只需要**签署新应用程序**。[阅读本页Smali - 反编译/\[修改\]/编译部分以了解如何签署](/mobile-pentesting/android-app-pentesting/smali-changes.md#sing-the-new-apk)。

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>

**Try Hard Security Group**

<img src="/files/Kw46fTSYxPIOMyKySfL5" alt="" data-size="original">

支持HackTricks的其他方式：

* 如果您想在HackTricks中看到您的**公司广告**或**下载PDF版本的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或在**Twitter**上关注我们 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hacktricks.xsx.tw/mobile-pentesting/android-app-pentesting/make-apk-accept-ca-certificate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
