0

I am trying to connect via an Android 5.1 device using the Okhttp library to a server with TLS 1.2 encryption. When trying to connect:

SSL handshake aborted error occurs: ssl = 0xaXXXXXXXX: I / O error during system call, Connection reset by peer.

I was looking for a solution to the problem on the Internet, but the problem is that Google Play services are not installed on my target devices.

How can this problem be solved?

This code is checked and working on devices android 7-9 with Google Play services

    OkHttpClient client = new OkHttpClient();
    String url = "https://domen/app/rest/v2/oauth/token";
    String credential = Credentials.basic("username", "password");
    RequestBody requestBody = new MultipartBody.Builder()
            .setType(MultipartBody.FORM)
            .addFormDataPart("grant_type", "password")
            .addFormDataPart("username", login)
            .addFormDataPart("password", password)
            .build();
    Request request = new Request.Builder()
            .post(requestBody)
            .header("Authorization", credential)
            .url(url)
            .build();
Dot
  • 1
  • 3
  • Share some code for better understanding. – Sanwal Singh Jul 04 '19 at 06:43
  • you don't have to change anything in app. check your domain have proper chain certificate or not.https://www.sslshopper.com/ssl-checker.html Don't west your time to fix from app side. its totally issue with back-end. – KuLdip PaTel Jul 04 '19 at 08:18
  • @KuLdipPaTel , ssl certificate verification is successful – Dot Jul 04 '19 at 08:26
  • Does your android application (or your client) TRUST the CA which issued the certificate to your server having TLS enabled? This is the basic requirement. – A_C Jul 04 '19 at 11:41
  • @AnkurChrungoo How to make the client trust the certificate authority? In the case of Android 9, the connection is successful. – Dot Jul 04 '19 at 12:13
  • @Dot it would require importing the CA's certificate in the client's trust store / trusted CA authorities list – A_C Jul 04 '19 at 12:17
  • Probably this can help https://stackoverflow.com/questions/4461360/how-to-install-trusted-ca-certificate-on-android-device – A_C Jul 04 '19 at 12:22
  • @AnkurChrungoo Is it possible to bypass certificate verification? – Dot Jul 04 '19 at 12:28
  • @Dot I wouldn't recommend doing that. It should be easy to import the root CA certificate into your client's Trusted Root CA authorities. This is very basic thing to do, and once it is done, your application should work over TLS. – A_C Jul 04 '19 at 12:35

0 Answers0