October 22, 2024
Chicago 12, Melborne City, USA
Android

Howto use TLS 1.0 in Android


I want to connect to a local device which supports only TLS 1.0. The device’s firmware cannot be updated thus I am stuck to this protocol version.

SSLContext sslContext = SSLContext.getInstance("TLSv1");
sslContext.init(null, null, null);
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();

URL url = new URL("https://192.168.1.10/command?action=2");
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setSSLSocketFactory(sslSocketFactory);

// Create an InputStreamReader to read the response
BufferedReader reader = new BufferedReader(new InputStreamReader(httpsURLConnection.getInputStream()));

// Read the response line by line and append it to the StringBuilder
StringBuilder result = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
    result.append(line);
}

// Close the reader and connection
reader.close();
httpsURLConnection.disconnect();
return result.toString();

But this code raises the following exception:

javax.net.ssl.SSLHandshakeException: Read error: ssl=0x79b5fc7008: Failure in SSL library, usually a protocol error
error:100000f0:SSL routines:OPENSSL_internal:UNSUPPORTED_PROTOCOL (external/boringssl/src/ssl/handshake_client.cc:714 0x7ad8a4ad53:0x00000000)
    at com.android.org.conscrypt.SSLUtils.toSSLHandshakeException(SSLUtils.java:356)

Is there a way to connect to the server using TLS v1 in Android?

Regards,



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video