I have an Android project and it works well at my test environment with test environment certificate. And now, I must connect this app to client's UAT environment instead of test environment. From client's web site, I downloaded public certificate and added it to Android application with replacing test environment certiface. When I tested application, I took below error.
What does this error mean? Is the error about server side config? Should I add this certificate to trusted certificates of Android OS?
EDIT: The downloaded certiface from the client's web site is CA certificate. Not a self signed certificate.
W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
W/System.err: at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:236)
W/System.err: at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:367)
W/System.err: at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:325)
W/System.err: at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:197)
W/System.err: at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:249)
W/System.err: at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:108)
W/System.err: at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:76)
W/System.err: at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:245)
W/System.err: at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
W/System.err: at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:96)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
W/System.err: at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
W/System.err: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
W/System.err: at xbnvqqyqoxeynry.dxdxdd.intercept(Unknown Source:29)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
W/System.err: at xbnvqqyqoxeynry.xxxxdx.intercept(Unknown Source:4)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
W/System.err: at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
W/System.err: at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:502)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err: at java.lang.Thread.run(Thread.java:764)
W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:654)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:499)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:422)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:343)
W/System.err: at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
W/System.err: at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
W/System.err: at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:208)
W/System.err: at com.android.org.conscrypt.ConscryptFileDescriptorSocket.verifyCertificateChain(ConscryptFileDescriptorSocket.java:426)
W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
W/System.err: at com.android.org.conscrypt.NativeSsl.doHandshake(NativeSsl.java:383)
W/System.err: at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:231)
W/System.err: ... 24 more
W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
W/System.err: ... 35 more
I think you need to create a network_security_config.xml in res/xml and also you need to configure it. For example:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config>
<trust-anchors>
<certificates src="#raw/certificate_name"/>
<certificates src="system"/>
</trust-anchors>
</base-config>
After this, you should add the network_security_config to AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="#xml/network_security_config"
... >
...
</application>
For more information: https://developer.android.com/training/articles/security-config.html
Related
I am trying to use a government api (https://api.usno.navy.mil/rstt/oneday?date=8/8/2019&coords=48.39,-115.56&tz=-7) to get sunrise and sunset type information and I get the error java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. I was having the same problems using the Chrome browser on Windows 10 until I imported the government certificates.
However, I can not figure out how to get the Android Studio emulator to recognize the certs (I will worry about my Nexus 6 device after I get everything working in the emulator).
I have a file of the government certs and have added them to Android Studio using Settings/tools/ServerCertificates. The certs I have added are DOD ID SW CA-38, DoD Root CA 2, DoD Root CA 3, and DoD Root CA 4. When I look at the certificate path on the browser, it shows DoD Root CA 3, DOD ID SW CA-38 and api.usno.navy.mil. The api.usno.navy.mil cert was issued by DOD ID SW CA-38.
I have tried setting the Server Certificates to "Accept non-trusted certificates automatically" (not my favorite option).
All were no help. I have also looked through the stackoverflow messages that seem related and did not find a solution. I am trying to not use third party apps.
Although it was not apparently needed in the browser, could there be some other certificate specifically for the api.usno.navy.mil reference?
The usno (U.S. Naval Observatory) has requested certificates that are more generally acknowledged (versus the DoD certificates), but they don't know when the administrators will provide them.
How can I get the Android Studio emulator to recognize these DoD certificates?
Any suggestions would be appreciated. Thanks.
Complete stack trace follows:
4424-4451/com.drme.weathertest W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
4424-4451/com.drme.weathertest W/System.err: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms#13280022#13.2.80 (040700-211705629):47)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:192)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:149)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:244)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
4424-4451/com.drme.weathertest W/System.err: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(Unknown Source:0)
4424-4451/com.drme.weathertest W/System.err: at com.drme.weatherNoaa.NetworkHelpers.getUrlBytes(NetworkHelpers.java:123)
4424-4451/com.drme.weathertest W/System.err: at com.drme.weatherNoaa.SunMoonWebRunnable.run(SunMoonWebRunnable.java:108)
4424-4451/com.drme.weathertest W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
4424-4451/com.drme.weathertest W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
4424-4451/com.drme.weathertest W/System.err: at java.lang.Thread.run(Thread.java:764)
4424-4451/com.drme.weathertest W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
4424-4451/com.drme.weathertest W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:646)
4424-4451/com.drme.weathertest W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:495)
4424-4451/com.drme.weathertest W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:418)
4424-4451/com.drme.weathertest W/System.err: at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:339)
4424-4451/com.drme.weathertest W/System.err: at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
4424-4451/com.drme.weathertest W/System.err: at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
4424-4451/com.drme.weathertest W/System.err: at java.lang.reflect.Method.invoke(Native Method)
4424-4451/com.drme.weathertest W/System.err: at com.google.android.gms.org.conscrypt.Platform.checkTrusted(:com.google.android.gms#13280022#13.2.80 (040700-211705629):2)
4424-4451/com.drme.weathertest W/System.err: at com.google.android.gms.org.conscrypt.Platform.checkServerTrusted(:com.google.android.gms#13280022#13.2.80 (040700-211705629):1)
4424-4451/com.drme.weathertest W/System.err: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.verifyCertificateChain(:com.google.android.gms#13280022#13.2.80 (040700-211705629):5)
4424-4451/com.drme.weathertest W/System.err: at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
4424-4451/com.drme.weathertest W/System.err: at com.google.android.gms.org.conscrypt.NativeSsl.doHandshake(:com.google.android.gms#13280022#13.2.80 (040700-211705629):8)
4424-4451/com.drme.weathertest W/System.err: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms#13280022#13.2.80 (040700-211705629):15)
4424-4451/com.drme.weathertest W/System.err: ... 18 more
My Android app does not work on https call at First Run After Installation.
And then restart app after https call is fine. Only First Run After Installation does not working.
My App use multiple network class Socket(for tcp/ip), Http wrapped class(HttpClient, HttpGet)
**Error Log -----------------------------------------------**
D/InputTransport: Input channel destroyed: fd=91
I/SemDesktopModeManager: unregisterListener: android.view.ViewRootImpl$3#b979a69
I/System.out: AsyncTask #2 calls detatch()
W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:368)
W/System.err: at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:406)
W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:219)
W/System.err: at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:172)
W/System.err: at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:130)
W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.executeOriginal(DefaultRequestDirector.java:1334)
W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:700)
W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:560)
W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:658)
W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:632)
W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:621)
W/System.err: at com.yuanta.mainlib.view.alarm.EventHttpProcessor$NoticeAsyncTask.doInBackground(EventHttpProcessor.java:63)
W/System.err: at com.yuanta.mainlib.view.alarm.EventHttpProcessor$NoticeAsyncTask.doInBackground(EventHttpProcessor.java:51)
W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:304)
W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
W/System.err: at java.lang.Thread.run(Thread.java:762)
W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:546)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:427)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:491)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:491)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:387)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:361)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:290)
W/System.err: at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
W/System.err: at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
W/System.err: at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:178)
W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:617)
W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:364)
W/System.err: ... 18 more
W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
W/System.err: ... 31 more
I/System.out: Thread-2620(ApacheHTTPLog):isSBSettingEnabled false
I/System.out: Thread-2620(ApacheHTTPLog):isShipBuild true
I/System.out: Thread-2620(ApacheHTTPLog):getDebugLevel 0x4f4c
I/System.out: Thread-2620(ApacheHTTPLog):Smart Bonding Setting is false
Did you add these in your manifest?
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I'm having trouble connecting Android studio emulator to Internet behind proxy.
I have enabled permission in android Manifest.xml
<uses-permission android:name="android.permission.INTERNET" />
And the app works perfectly well in USB Debug mode.
This is the error i get when i run the app on Emulator.
Following is my Logcat .
D/makeGitHubSearchQuery: Inside Function
D/makeGitHubSearchQuery: HTTP
D/makeGitHubSearchQuery: https://api.github.com/search/repositories?q=HTTP&sort=stars
D/OnOptionsItemSelected: action_search
W/System.err: java.net.UnknownHostException: Unable to resolve host "api.github.com": No address associated with hostname
W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:470)
W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
W/System.err: at java.net.InetAddress.getAllByName(InetAddress.java:215)
W/System.err: at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
W/System.err: at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188)
W/System.err: at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157)
W/System.err: at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100)
W/System.err: at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357)
W/System.err: at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340)
W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)
W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384)
W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:231)
W/System.err: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
W/System.err: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java)
W/System.err: at com.example.android.datafrominternet.utilities.NetworkUtils.getResponseFromHttpUrl(NetworkUtils.java:76)
W/System.err: at com.example.android.datafrominternet.MainActivity$GithubQueryTask.doInBackground(MainActivity.java:77)
W/System.err: at com.example.android.datafrominternet.MainActivity$GithubQueryTask.doInBackground(MainActivity.java:71)
W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
W/System.err: at java.lang.Thread.run(Thread.java:818)
W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
W/System.err: at libcore.io.Posix.android_getaddrinfo(Native Method)
W/System.err: at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:451)
Please guide me in setting the Proxy settings in Android emulator.
Use this command to open emulator with the desired proxy.
emulator -avd [emulator_name] -http-proxy [proxy ip address]:[port]
official docs
I tried adding a retry policy (https://stackoverflow.com/a/22169775/2098493)
but the error persist when file being uploaded is larger than 1mb.
W/System.err: com.android.volley.NoConnectionError: javax.net.ssl.SSLException: Write error: ssl=0xafc3fe00: I/O error during system call, Connection reset by peer
W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151)
W/System.err: at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
W/System.err: Caused by: javax.net.ssl.SSLException: Write error: ssl=0xafc3fe00: I/O error during system call, Connection reset by peer
W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_write(Native Method)
W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:765)
W/System.err: at com.android.okio.Okio$1.write(Okio.java:70)
W/System.err: at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116)
W/System.err: at com.android.okio.RealBufferedSink.write(RealBufferedSink.java:44)
W/System.err: at com.android.okhttp.internal.http.RetryableSink.writeToSocket(RetryableSink.java:77)
W/System.err: at com.android.okhttp.internal.http.HttpConnection.writeRequestBody(HttpConnection.java:240)
W/System.err: at com.android.okhttp.internal.http.HttpTransport.writeRequestBody(HttpTransport.java:77)
W/System.err: at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:622)
W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:388)
W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:500)
W/System.err: at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
W/System.err: at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
W/System.err: at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:110)
W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:96)
Thanks for your advice.
The solution was a combination of adding Volley Retry Policy and making sure back-end and server (nodejs/nginx) max uploaded file size are both set correctly.
//where RETRY_DEFAULT_TIMEOUT_MS = 5000, RETRY_DEFAULT_MAX_RETRIES = 3, RETRY_DEFAULT_BACKOFF_MULT = 2.0f
request.setRetryPolicy(new DefaultRetryPolicy(RETRY_DEFAULT_TIMEOUT_MS,
RETRY_DEFAULT_MAX_RETRIES,
RETRY_DEFAULT_BACKOFF_MULT));
I have a simple code and there is an exception coming, can't figure out why?
My code:
Document document= Jsoup.connect("https://kolkatatrafficpolice.net/").get();
Stack trace:
javax.net.ssl.SSLHandshakeException: Connection closed by peer
W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
W/System.err: at com.android.okhttp.Connection.connectTls(Connection.java:235)
W/System.err: at com.android.okhttp.Connection.connectSocket(Connection.java:199)
W/System.err: at com.android.okhttp.Connection.connect(Connection.java:172)
W/System.err: at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
W/System.err: at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:247)
W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)
W/System.err: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
W/System.err: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java)
W/System.err: at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:571)
W/System.err: at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:548)
W/System.err: at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:235)
W/System.err: at org.jsoup.helper.HttpConnection.get(HttpConnection.java:224)
W/System.err: at com.pritesh.trafficviolation.GetHtml.doInBackground(MainActivity.java:29)
That server is using an unrecognized certificate authority.
If this is your server, and you are intentionally doing this (e.g., this is a self-signed certificate), you would need to configure JSoup/OkHttp to use that self-signed certificate.
Otherwise, your problems lie with the server.