11

When I'm using the fetch function in my react native apps, things work as expected on iOS, but gives an error in android. The error is 'TypeError: Network request failed'. Doing a bit of debugging, I found that the cause of the error seems to be the following: 'java.security.cert.CertPathValidatorException: Trust anchor for certification path not found'.

How come this works in iOS and not on android, and how do I best fix it? Is the fault in react-native, or somewhere deeper?

3
  • 1
    It's probably a server certificate issue. What is the server from where are you trying to fetch? Make sure you check your server's ssl certificate with this website digicert.com/help or with running. openssl s_client -debug -connect www.thedomaintocheck.com:443 Commented Jul 5, 2016 at 6:38
  • they are two separate devices. iOS might have trust established. Commented Aug 7, 2016 at 8:50
  • If you're using Expo, see my answer here: stackoverflow.com/a/70775576/4350421. Hope it helps :) Commented Jan 19, 2022 at 18:24

1 Answer 1

4

There is a few workarounds for this issue mentioned here: Trust Anchor not found for Android SSL Connection

However, if you are the server owner. I would suggest to review your server ssl certificate. I think that was because of missing CA certificate in your pem file. What I have done for my site is I created fullchain.pem by concating content of file.crt and file.ca-bundle as that order.

Then I configure nginx (my server behind nginx) with: ssl_certificate /etc/nginx/ssl/fullchain.pem;

The original document: https://www.digicert.com/ssl-certificate-installation-nginx.htm

Hope that helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.