androidandroid-studioperformance-testingloadrunner

How to add CA certificate to system trust store in android mobile?


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?


Solution

  • 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.

    1. add the next line to the application section of your application manifest

      android:networkSecurityConfig="@xml/network_security_config"
      
    2. 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>
      
    3. build your app in debug mode

    4. replace original .apk with the one you've just built on the device

    More information: Configure Android Devices for Proxy Recording