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();