Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] paho and tlsv1.2

Hi,

I learnt from http://stackoverflow.com/questions/16531807/android-client-server-on-tls-v1-2 that to use tlsv1.2 I have to enable that on the client socket using setEnabledProtocols(). Below is the code I use to create tlsv1.2 connection to mosquitto (using tlsv1.2):

SSLContext context = null;
KeyStore ts = KeyStore.getInstance("bks");
ts.load(getResources().openRawResource(R.raw.test666), "123456".toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");

tmf.init(ts);
TrustManager[] tm = tmf.getTrustManagers();
context = SSLContext.getInstance("TLSV1.2");
context.init(null, tm, null);
SocketFactory factory = context.getSocketFactory();
conOpt.setSocketFactory(factory);
connection.addConnectionOptions(conOpt);
Connections.getInstance(this).addConnection(connection);
client.connect(conOpt, null, callback);


The above code always hit error:

MqttException (0) - javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb97b2970: Failure in SSL library, usually a protocol error
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version (external/openssl/ssl/s23_clnt.c:741 0x9c3c3b11:0x00000000)

Any idea?


Thanks
Romu


Back to the top