英文:
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
你需要拥有一个已root的手机,才能够将自签名的MITM证书添加到操作系统中。
或者,你可以修改你的应用程序的网络安全配置,以信任用户安装的证书。
-
android:networkSecurityConfig="@xml/network_security_config"
-
在你的应用程序资源文件夹中创建
network_security_config.xml
文件,并将以下代码放入其中:<?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>
-
以调试模式构建你的应用程序。
-
用你刚刚构建的应用程序替换原始的.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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论