Skip to main content

Resolve network logs generation or insecure certificate error issues

Learn about how to set up your app correctly when you receive the BROWSERSTACK_NETWORK_LOGS_NOT_CAPTURED error or the BROWSERSTACK_INSECURE_CERTIFICATE_ERROR error in this section.

Issue

When you run a test using BrowserStack App Automate, the following errors might appear on the App Automate dashboard or in the REST API response :

  • [BROWSERSTACK_NETWORK_LOGS_NOT_CAPTURED] To view network logs on this device, please ensure that **browserstack.networkLogs=true** in input capabilities and your **app is set up correctly**. Please refer to our troubleshooting guide for more information. If error persists, reach out to support
  • [BROWSERSTACK_INSECURE_CERTIFICATE_ERROR] Unable to set up insecure certificate capability for your app. Please refer to our troubleshooting guide. If error persists, please reach out to support.

Cause

BrowserStack uses mitmproxy to capture network logs. This requires the mitmproxy CA certificate to be installed on all BrowserStack remote devices. As per Android’s official docs, apps do not trust user or admin-added CAs by default. As a result, certificates issued by applications like mitmproxy are no longer accepted and these proxies are not able to capture the network traffic to produce network logs or bypass invalid certificate errors when using a self-signed certificate.

Resolution

In order to successfully generate network logs or avoid invalid certificate errors, your app needs to be configured to trust user added CAs through the Network Security Configuration feature.
Please complete these 2 steps so that your app trusts user added CAs:

  • Step 1: The Network Security Configuration feature uses an XML file where you specify the settings for your app. Create this file in your project directory if it is already not present, and add the following code to it:
<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>
  • Step 2: Include the ‘android:networkSecurityConfig’ entry in the manifest of your app and set it to the path of this file. The following code excerpt from a manifest demonstrates how to create this entry:
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config"
                    ... >
        ...
    </application>
</manifest>
Note:
  • Ensure that all your apps, including the main app and any dependent apps (other apps or mid-session install apps), which you might use in a session, are configured to trust user-added CAs.
  • The provided resolution is only applicable for debuggable apps

Need some help?

If you need additional help, contact our Support team.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Download Copy