powered by Jive Software

SASLError using DIGEST-MD5: malformed-request

AbstractXMPPConnection conn = null;

XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();

config.setUsernameAndPassword(“username”, “password”);

config.setSecurityMode(ConnectionConfiguration.SecurityMode.required);

config.setServiceName(“example.es”);

config.setDebuggerEnabled(true);

config.setResource(“a”);

config.setHost(“10.2.2.2”);

config.setPort(80);

try {

SSLContext sc = SSLContext.getInstance(“TLS”);

MemorizingTrustManager mtm = new MemorizingTrustManager(this);

sc.init(null, new X509TrustManager[] { mtm }, new SecureRandom());

config.setCustomSSLContext(sc);

config.setHostnameVerifier(mtm.wrapHostnameVerifier(new org.apache.http.conn.ssl.StrictHostnameVerifier()));

} catch (NoSuchAlgorithmException | KeyManagementException e) {

throw new IllegalStateException(e);

}

conn = new XMPPTCPConnection(config.build());

conn.setPacketReplyTimeout(10000);

try {

conn.connect();

            conn.login();

} catch (SmackException | IOException | XMPPException e) {

e.printStackTrace();

conn.disconnect();

}

When I try to connect to the server I get this error:

org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: malformed-request

W/System.err﹕ at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthenticati on.java:365)

W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1033)

W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:937)

W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:952)

W/System.err﹕ at java.lang.Thread.run(Thread.java:841)

It could be this? I send you an image with my traces and another with the traces of yaxim
1113-04-2014(1).docx (68033 Bytes)

Debug info:

D/SMACK﹕ SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘do.om2m.es’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’ from=‘ana@do.om2m.es’ xml:lang=‘en’>

D/SMACK﹕ RECV (0): <?xml version='1.0'?><stream:stream xmlns:stream=‘http://etherx.jabber.org/streams’ xmlns=‘jabber:client’ to=‘ana@do.om2m.es’ from=‘do.om2m.es’ version=‘1.0’ id=‘c6lnnur0rabjivpvqkq1ishk3jbpuzs66ett8luz’ xmlns:ack=‘http://www.xmpp.org/extensions/xep-0198.html#ns’>

D/SMACK﹕ RECV (0): <stream:features xmlns:stream=‘http://etherx.jabber.org/streams’>10.1.8.23<auth xmlns='http://jabber.org/features/iq-auth’/><register xmlns='http://jabber.org/features/iq-register’/></stream:features >

D/SMACK﹕ SENT (0):

D/SMACK﹕ RECV (0):

D/SMACK﹕ SENT (0): <stream:stream xmlns=‘jabber:client’ to=‘do.om2m.es’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’ from=‘ana@do.om2m.es’ xml:lang=‘en’>

D/SMACK﹕ RECV (0): <?xml version='1.0'?><stream:stream xmlns:stream=‘http://etherx.jabber.org/streams’ xmlns=‘jabber:client’ to=‘ana@do.om2m.es’ from=‘do.om2m.es’ version=‘1.0’ id=‘5je099rtzscrawuu8ko8dverp8za3z68ik9rt0ls’ xmlns:ack=‘http://www.xmpp.org/extensions/xep-0198.html#ns’>

D/SMACK﹕ RECV (0): <stream:features xmlns:stream=‘http://etherx.jabber.org/streams’>10.1.8.23EXTERNALPLAINDIGEST-MD5<auth xmlns='http://jabber.org/features/iq-auth’/><register xmlns='http://jabber.org/features/iq-register’/></stream:features>

D/SMACK﹕ SENT (0): =

D/SMACK﹕ RECV (0): cmVhbG09ImRvLm9tMm0uZXMiLCBub25jZT0iam FpdlJ6TGVRcEQvOHBhM3NDR1hLUT09IiwgcW9wPSJhdXRoIiwgY2hhcnNldD11dGYtOCwgYWxnb3JpdG htPW1kNS1zZXNz

D/SMACK﹕ SENT (0): dXNlcm5hbWU9ImFuYSIscmVhbG09ImRvLm9tMm 0uZXMiLG5vbmNlPSJqYWl2UnpMZVFwRC84cGEzc0NHWEtRIixjbm9uY2U9Ikt6MmNFNWRQOTFSNjc2SU tSdHYybG82R2d0RzZKTHpsIixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwL2RvLm 9tMm0uZXMiLHJlc3BvbnNlPTQ5MzcwMmU1MWYxY2RhM2YyODUxNjY0MTFlYzYwZjhiLGNoYXJzZXQ9dX RmLTg=

D/SMACK﹕ RECV (0):

org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: malformed-request

org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthenticatio n.java:365)

org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPCo nnection.java:1033)

org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConn ection.java:937)

org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnectio n.java:952)

at java.lang.Thread.run(Thread.java:841)

D/SMACK﹕ SENT (0):

D/SMACK﹕ SENT (0): </stream:stream>

Which XMPP server is sending the malformed-request?

jabberd2

I disabled DIGEST-MD5 mechanism in server and it now appears to work fine.

You may want to report this to the jabberd2 developers. While I’m not 100% positive that this is a server bug, I think it’s very likely as Smack works fine using DIGEST-MD5 and other XMPP servers.

Hopefully you are using a better SASL mechanism now and not PLAIN. Which one do you use?

Ok. thanku

I use PLAIN but with TLS

We also have DIGEST-MD5 malformed request problem.

Here is the original Xabber issue about 1,5 year old:

Error connecting to jabberd2 server: SASLError using DIGEST-MD5: malformed-request · Issue #542 · redsolution/xabber-and…

It happens for jabberd2 server at least.

Jabberd2 developers answered that “There is a wrong nonce in Smack response.”

Fail DIGEST-MD5 connections from some Smack based apps. · Issue #103 · jabberd2/jabberd2 · GitHub

I reproduced this problem with latest Smack 4.2.1 snapshot using jabber.no-sense.net server

Here is the log:

2017-04-07 Smack DIGEST-MD5 malformed request for jabberd2 · GitHub

Thanks, that was helpful. Created [SMACK-755] DIGEST-MD5 sometimes causes malformed request server response - IgniteRealtime JIRA and fixed with Fix provided SASL DIGEST-MD5 mechanism · Flowdalic/Smack@99c31d0 · GitHub