I am trying to consume RestApi from asp.net running in (local machine). I followed the exact steps on https://developer.android.com/training/articles/security-config#ConfigCustom in (Configure a custom CA)
but with no success, always getting the same error "java.security.cert.CertPathValidatorException: Trust anchor for certification path not found".
Steps i followed:
1- Exporsted the self-signed CA in .der from (Trusted Root Certification Authorities) convert it to .pem, i took copy of the .pem and pasted(added it) to raw directory.
2- Created "network_security_config".
<network-security-config>
<domain-config>
<domain includeSubdomains="true">10.0.2.2</domain>
<trust-anchors>
<certificates src="@raw/localhost"/>
</trust-anchors>
</domain-config>
</network-security-config>
3- Modified AndroidManifest:
<application
android:networkSecurityConfig="@xml/network_security_config"
...
</application
Finally: in retrofit baseUrl("https://10.0.2.2:5001/api/")