I'm developing an Android App that must access a Web API on localhost:44323 (connected by reverse TCP on ADB) to retrieve data. Problem is, when trying to make a request with Volley, it throws out a SSL error. Now, this is expected, but i can't put the IIS Express development certificate on the app. I've tried obtaining the certficate in PEM format with Firefox and by exporting from Windows' certificate manager, putting it on res/raw/my_ca.pem, and referencing it on the network configuration XML as follows:
<network-security-config>
<domain-config>
<domain includeSubdomains="true">localhost</domain>
<trust-anchors>
<certificates src="@raw/my_ca"/>
</trust-anchors>
</domain-config>
</network-security-config>
And on the AndroidManifest.xml
<application
...
android:networkSecurityConfig="@xml/network_security_config">
However, when trying to make a request on Volley, it throws:
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
07-15 16:49:35.241 8253-8253/teste.br.projetoteste W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:328)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:103)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.Connection.connect(Connection.java:143)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:185)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:341)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:99)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:131)
07-15 16:49:35.242 8253-8253/teste.br.projetoteste W/System.err: ... 2 more