Skip to main content
🚀 Self Healing AI Agent now live in App Automate! Auto-fix flaky tests instantly with zero code changes. Enable now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Fix certificate pinning failures with network logs

Fix Appium test failures on App Automate that occur when network logs are enabled and your app uses certificate pinning.

If your app uses certificate pinning, your tests can fail when you enable network logs. Network requests between your app and its pinned hosts fail because of how BrowserStack captures network logs, not because of the device. Exclude the pinned hosts from network log capture to fix these failures.

Common issues

When network logs break certificate-pinned traffic, the failure usually shows up in your app’s UI rather than as a BrowserStack error. The following issues might appear:

  • Login doesn’t complete, or an infinite loading spinner appears after login.
  • Webviews or in-app pages load as blank white screens.
  • Maps, ads, live chat, or other content sections don’t load.
  • Deep links fail, show an SSL error page, or open in the browser instead of your app.
  • Your app shows an “unable to connect to server” or generic network error.
  • Payment or third-party redirects, such as a payment gateway login page, don’t open.
  • The device logs show SSL handshake errors.

Why certificate pinning fails with network logs

App developers use certificate pinning to prevent man-in-the-middle attacks and enhance the app’s security. Using certificate pinning, the app developer associates, or pins, a remote host or service with its certificate or public keys at the time of development. When the app makes a network request to a remote host, the app compares the pinned certificate with the remote server’s certificate to verify the host’s identity.

BrowserStack uses a MITM proxy to capture network logs. When network logs are enabled, this proxy causes network requests between your app and its pinned hosts to fail.

Third-party SDKs in your app can also pin certificates, so the failing hosts aren’t always your own APIs. For example, ads, maps, and payment SDKs can connect to pinned hosts.

The acceptInsecureCerts capability also routes your app’s traffic through a proxy, so it can cause the same certificate pinning failures. The capability doesn’t fix pinning failures. If your app pins certificates, remove acceptInsecureCerts from your configuration. For more information, see Accept insecure certificates.

Confirm that network logs cause the failure

Run the same test twice on the same device: once with networkLogs set to true and once with it set to false. If the test passes with network logs disabled and fails with them enabled, the network log proxy is the cause.

Find the hosts to exclude

The hosts to exclude depend on your app. To find them, try the following:

  • Ask your app developers which hosts your app and its third-party SDKs pin certificates for.
  • Check the device logs of the failed session for SSL handshake errors. These errors show which requests failed.

Exclude certificate-pinned hosts

Use the exclude hosts capability to bypass the BrowserStack MITM proxy for requests to certificate-pinned hosts. Your tests run successfully and BrowserStack still captures network logs for all other hosts. Requests to excluded hosts don’t appear in your network logs.

If you use the BrowserStack SDK, set networkLogsExcludeHosts in the browserstack.yml file. Pass this capability at the top level, not inside networkLogsOptions.

Capability Description Value
networkLogsExcludeHosts Specifies certificate-pinned hosts that bypass the BrowserStack MITM proxy. Your tests run successfully and network logs are still captured for all other hosts. List of certificate pinned hosts (Array) or regex value (String)

The following example excludes requests made to google.com from network log capture:

browserstack.yml
Copy icon Copy

Instead of a list, you can pass a regex value as a string. The following example excludes requests made to example.com and its subdomains:

browserstack.yml
Copy icon Copy

Only HTTPS URLs are ignored for the specified hosts.

The following rules apply to host filtering:

  • networkLogsExcludeHosts requires networkLogs to be true. Omitting networkLogs: true fails the session with tls_passthrough_networklogs_cap_not_set.
  • networkLogsExcludeHosts and networkLogsIncludeHosts are mutually exclusive. Passing both fails the session.
  • Each list accepts a maximum of 10 hosts, and each host entry, including a regex string, is capped at 200 characters.
  • Wildcards, such as *.example.com, aren’t supported. Use exact hostnames or a regex value.
  • Host filtering works at the host level only. You can’t include or exclude individual requests or paths on a host.

If excluding hosts doesn’t fix the failure

Try these fixes in order:

  1. Disable network logs for the session by setting networkLogs to false, its default value.
  2. If that doesn’t resolve the failure, disable SSL pinning in your test builds only. Never disable SSL pinning in production builds.

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 Check Circle