axios: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found (app in react-native)
Describe the bug
"axios": "^0.27.2",
I am writing an application in react-native.
I get an error when making GET requests:
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
everything that I managed to Google does not help.
I have already added android:networkSecurityConfig=“@xml/network_security_config” in AndroidManifest.xml and created a file xml/network_security_config.xml
<network-security-config xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<domain-config>
<domain includeSubdomains="true">{ip address of domain}</domain>
<domain includeSubdomains="true">{need domain}</domain>
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</domain-config>
</network-security-config>
But the error does not disappear… What to do?
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16
I solved the problem like this:
Made according to the instructions from here https://stackoverflow.com/questions/51902629/how-to-allow-all-network-connection-types-http-and-https-in-android-9-pie
I had the same problem but now I solved it
More context:
It seems to be a problem of the library
axios
(specificallyaxiosinstance
). Its weird because I didn’t change anything in the android app, it just suddenly stopped to work. (in all the android devices at the same time).And just doing tests I realized that
axiosinstance
fail by doing the request (with the exception that I already showed you), but in an inexplicable way if the first request pointing to my API that I do in the app is by usingaxios
it works perfectly, and after thataxiosinstance
is capable to perform any request to my API without fail.I know it sounds weird, but now my app is working again.
By other Side, just to let you know, I also tested an android app called
API Tester v5.6
and it fails connecting to my API giving me the same exception, but it last versionAPI Tester 5.7
(which was released just some days ago) works without problem.I also tried to connect to my API with
ApiClient v2.4.7
and it fails with the same exception.Again, I don’t understand what is the real problem but definitely is not the certificate. I left the commentary in here, maybe someone can reproduce it and check?
Same problem here. And I don’t know how to solve
Working fine with IOS but in Android sometimes it works.
Same problem here. And I don’t know how to solve
having the same issue when using ‘expo-video-player’