英文:
How to add CA certificate to system trust store in android mobile?
问题
我想测试使用LoadRunner测试移动应用程序的性能(服务器端)。我能够通过将LoadRunner代理证书推送到用户存储中来捕获Web应用程序的网络流量,但无法记录原生或混合应用程序的流量,因为应用程序显示错误消息 - "无互联网连接"。我了解到为了运行,证书应该存在于系统存储中。是否有任何方法可以将证书推送到系统信任存储中?
英文:
I want to test the performance(server-side) of the mobile application using LoadRunner. I'm able to capture network traffic for the web apps by pushing the LoadRunner proxy certificate to the user store and not able to record traffic for the native or hybrid apps since apps are showing error - "No internet connection". Got to know that in order to run the certificate should be present in system store. Is there any way to push certificate to the system trust store?
答案1
得分: 0
为了能够向操作系统添加自签名的MITM证书,您需要拥有一台已root的手机。
或者,您可以修改您的应用程序的网络安全配置,以信任用户安装的证书。
android:networkSecurityConfig="@xml/network_security_config"
- 在您的应用程序资源文件夹中创建
network_security_config.xml
文件,并将以下代码放入其中:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<debug-overrides>
<trust-anchors>
<!-- 仅在可调试模式下信任用户添加的CA -->
<certificates src="user"/>
</trust-anchors>
</debug-overrides>
</network-security-config>
- 在调试模式下构建您的应用程序。
- 用您刚刚在设备上构建的那个替换原始的.apk文件。
更多信息:配置Android设备以进行代理录制
英文:
You need to have a rooted phone in order to be able to add a self-signed MITM certificate to the operating system.
Alternatively you can amend your application network security configuration in order to trust user-installed certificates.
-
add the next line to the application section of your application manifest
android:networkSecurityConfig="@xml/network_security_config"
-
create
network_security_config.xml
file in your application resources folder and put the following code there<?xml version="1.0" encoding="utf-8"?> <network-security-config> <debug-overrides> <trust-anchors> <!-- Trust user added CAs while debuggable only --> <certificates src="user"/> </trust-anchors> </debug-overrides> </network-security-config>
-
build your app in debug mode
-
replace original .apk with the one you've just built on the device
More information: Configure Android Devices for Proxy Recording
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论