Quantcast
Channel: Ignite Realtime : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 10742

(a)Smack 4.0 rc2 and SASL authentication

$
0
0

Hello. I'm having some trobble to connect to tigase server. I did some attempts.

Asmack version: asmack-android-8-4.0.0-rc2-SNAPSHOT-2014-04-23.jar

Source:

 

connConfig.setDebuggerEnabled(DEBUG_ENABLED);

connConfig.setReconnectionAllowed(false);

connConfig.setCompressionEnabled(false);

connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);

connConfig.setSocketFactory(SSLSocketFactory.getDefault());

connection = new XMPPTCPConnection(connConfig);

connection.addConnectionListener(connectionListener);

connection.connect();

 

I get the follow exception:

javax.net.ssl.SSLException: Connection closed by peer

05-02 16:13:02.499    6906-6953/com.movile.movilechatmvp W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)

05-02 16:13:02.499    6906-6953/com.movile.movilechatmvp W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLS ocketImpl.java:398)

05-02 16:13:02.499    6906-6953/com.movile.movilechatmvp W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.<init>(O penSSLSocketImpl.java:645)

05-02 16:13:02.499    6906-6953/com.movile.movilechatmvp W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.getInputStream(OpenSSLS ocketImpl.java:616)

 

If I removed this line : "connConfig.setSocketFactory(SSLSocketFactory.getDefault());" I got:

rg.apache.harmony.javax.security.sasl.SaslException: No non-anonymous SASL authentication mechanism available

05-02 16:19:53.730    7089-7135/com.movile.movilechatmvp W/System.err﹕ at org.jivesoftware.smack.XMPPTCPConnection.login(XMPPTCPConnection.java:239)

05-02 16:19:53.730    7089-7135/com.movile.movilechatmvp W/System.err﹕ at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:376)

 

I'm not sure about the right way to connect using TLS/ SASL... =/  I found a issue in jira (http://issues.igniterealtime.org/browse/SMACK-454) and I beliave tigase expect compression before resource bind...

I also tried the following code:

 

ConnectionConfiguration connConfig = new ConnectionConfiguration(serverHost);

 

        connConfig.setDebuggerEnabled(DEBUG_ENABLED);

        connConfig.setReconnectionAllowed(false);

        connConfig.setCompressionEnabled(false);

        connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);

        //connConfig.setSocketFactory(SSLSocketFactory.getDefault());

 

        try {

            SSLContext sc = SSLContext.getInstance("TLS");

            sc.init(null, null, new SecureRandom());

            connConfig.setCustomSSLContext(sc);

        } catch (NoSuchAlgorithmException e) {

            throw new IllegalStateException(e);

        } catch (KeyManagementException e) {

            throw new IllegalStateException(e);

        }

        connection = new XMPPTCPConnection(connConfig);

        connection.addConnectionListener(connectionListener);

        connection.connect();

 

and  I realized that serverMechanisms at SASLAuthentication has no value (serverMechanisms.size = 0) and because that I got this error message:

SASL Authentication failed. No known authentication mechanisims.

 

Is not clear to me the right approach to create a secure connection. Could someone give me some light? Is there a mistake in my attempts to create a secure connection ?

 

Thanks in advanced.


Viewing all articles
Browse latest Browse all 10742

Trending Articles