Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pinnedCertificates() breaks the Countly connection (Android) #442

Open
km4r opened this issue Jan 16, 2025 · 7 comments
Open

pinnedCertificates() breaks the Countly connection (Android) #442

km4r opened this issue Jan 16, 2025 · 7 comments

Comments

@km4r
Copy link

km4r commented Jan 16, 2025

After the SDK update (23.10.0 -> 24.4.1) I don't see any new data in Countly coming from Android devices. I found out it's due to the
Countly.pinnedCertificates('count.ly.cer'); usage, however on SDK 23.10.0 the same config works fine.

Notes:

  • Certificate is valid for sure
  • reproducible only in the Release Mode on Android - in Debug Mode I haven't noticed any issues
  • checked also with previous SDK versions (23.12.0 and 24.4.0) - the same issue there
  • React Native version: 0.74.1
  • no issues on iOS
@turtledreams
Copy link
Contributor

Hi @km4r , I have tested this with latest version and it is working fine for me in release mode. Can you specify what error you are seeing? After enabling SDK logs you can see what is the issue from Android Studio's logcat. Also where/when you are calling pinnedCertificates, where did you save the certificate and such.

@km4r
Copy link
Author

km4r commented Jan 20, 2025

Hi @turtledreams

  1. Here is the error from Logcat:

Image

  1. I call pinnedCertificates right before the Countly init in the App.tsx file like this:
  useEffect(() => {

    ...

    (async () => {

     ...

      if (!(await Countly.isInitialized())) {
        Countly.pinnedCertificates('count.ly.cer');
        const countlyConfig = new CountlyConfig('COUNTLY_URL', 'COUNTLY_API');
        await Countly.initWithConfig(countlyConfig);
      }
    })();
  }, []);
  1. The count.ly.cer file is saved in android/app/src/main/assets/

@turtledreams
Copy link
Contributor

Hi @km4r , sorry for the delay. The way you provide the certificate seems correct. The ssl pinning code has not changed for quite a while so we think it should not be dependent on the sdk version change.
The error indicates an issue regarding subdomains. Did you set up a network security config for including subdomains? If that is the case there is no support for that currently. Will need to create a branch for it for you to test.

@km4r
Copy link
Author

km4r commented Jan 23, 2025

Thanks @turtledreams, do you mean this Android config?

<network-security-config>
    <base-config>
        <trust-anchors>
            <certificates src="user"/>
            <certificates src="system"/>
        </trust-anchors>
    </base-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">10.0.2.2</domain>
        <domain includeSubdomains="true">localhost</domain>
    </domain-config>
</network-security-config>

For now it looks like this - no specific config for the Countly Server there. Does the Countly.pinnedCertificates() method require an additional config somewhere else?

@turtledreams
Copy link
Contributor

Hi @km4r. I created a new branch for you. Can you try building with it and let me know if it works: https://github.com/Countly/countly-sdk-react-native-bridge/tree/androidn-pinned

@km4r
Copy link
Author

km4r commented Jan 27, 2025

Thank you @turtledreams, looks like the issue is fixed on the branch you provided

@turtledreams
Copy link
Contributor

@km4r great to hear that, will create a minor with the fix as soon as possible!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants