Android 7.1.1 SSLHandShakeException Connection Closed by Peer

Viewed 2608

First, I've already searched the internet and have been debugging for 3 days.

This is the exact error,

javax.net.ssl.SSLHandshakeException: Connection closed by peer
  at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:302)
  at com.android.okhttp.Connection.upgradeToTls(Connection.java:197)
  at com.android.okhttp.Connection.connect(Connection.java:151)
  at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276)
  at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
  at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
  at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
  at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:208)
  at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
  at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:25)
  at com.aws.wiremo.common.CommonFunctions.sendRequestEx(CommonFunctions.java:618)
  at com.aws.wiremo.common.CommonFunctions.sendRequest(CommonFunctions.java:556)
  at com.aws.wiremo.screen.kdo.LoadingScreen$MakeRequest.doInBackground(LoadingScreen.java:146)
  at com.aws.wiremo.screen.kdo.LoadingScreen$MakeRequest.doInBackground(LoadingScreen.java:125)
  at android.os.AsyncTask$2.call(AsyncTask.java:288)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  at java.lang.Thread.run(Thread.java:818)

Due to confidentiality reasons, I can't post the codes. There's no caused by exception given by the StackTrace so i can't really diagnose the problem.

Here are some information I can share.

  • Application is working in Android 5.0.2.
  • Request is being sent to https://[IP_address]:443/
  • I am sending a request to a special hardware, like a control box. I can only write and retrieve data through POST requests.
  • The certificate chain that I receive in my CustomTrustManager's checkServerTrusted method has a CN that is not an IP address and not a DNS, more like a word only (i.e. CN=commonname).
  • My HostNameVerifier is ALLOW_ALL_HOSTNAME_VERIFIER temporarily (which i think might solve the problem with the 3rd info?).
  • I am using a DummyTrustManager that trusts all certificates.
  • I am using SSLContext.getInstance("TLS").
  • The certificate being used is self-signed.
  • The certificate used by the hardware uses AES128 cipher.
  • Can successfully send request to another URL that uses a self-signed certificate with TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 cipher.


Any inputs or help will be appreciated.

1 Answers
Related