I have a backend built in Java and Springboot and deployed on railway. When i tested the endpoints on various Android versions from 14 till 6 and they all worked except on Android 7.0 (Nougat), where i keep getting this error message for every network request i make:
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
I haven't tried much of any solution. I use retrofit and it is for my android app in kotlin.
What do i do to solve it?
This exception is saying that phone doesn't trust the SSL Authority. As @Markus Kauppinen suggested in comment, you have to setup network security configuration.
Download your server certificate and save it into
rawresources directory.Create
network_security_configfile inxmlresources directory and setup configuration for your server domain. If your app communicates with other servers like Firebase, don't forget to include them too:In
network_security_config.xmljust replace yourdomain.com with your actual domain.AndroidManifest.xml, put in intoapplicationtagWith this solution it should work fine for Android 7+.