[asterisk-commits] bweschke: branch bweschke/originate_w_jabber r96860 - /team/bweschke/originat...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 7 10:07:00 CST 2008


Author: bweschke
Date: Mon Jan  7 10:06:59 2008
New Revision: 96860

URL: http://svn.digium.com/view/asterisk?view=rev&rev=96860
Log:
 Bringing r96499 in from /trunk res_jabber.c


Modified:
    team/bweschke/originate_w_jabber/res/res_jabber.c

Modified: team/bweschke/originate_w_jabber/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/originate_w_jabber/res/res_jabber.c?view=diff&rev=96860&r1=96859&r2=96860
==============================================================================
--- team/bweschke/originate_w_jabber/res/res_jabber.c (original)
+++ team/bweschke/originate_w_jabber/res/res_jabber.c Mon Jan  7 10:06:59 2008
@@ -814,8 +814,15 @@
 	char *s;
 	char *base64;
 
-	if (!(type && IKS_STREAM_SASL_PLAIN))
+	/* trigger SASL DIGEST-MD5 only over an unsecured connection.
+		iks_start_sasl is an iksemel API function and relies on GnuTLS,
+		whereas we use OpenSSL */
+	if ((type & IKS_STREAM_SASL_MD5) && !aji_is_secure(client))
+		return iks_start_sasl(client->p, IKS_SASL_DIGEST_MD5, username, pass); 
+	if (!(type & IKS_STREAM_SASL_PLAIN)) {
+		ast_log(LOG_ERROR, "Server does not support SASL PLAIN authentication\n");
 		return IKS_NET_NOTSUPP;
+	}
 
 	x = iks_new("auth"); 
 	if (!x) {
@@ -829,7 +836,12 @@
 	base64 = alloca((len + 2) * 4 / 3);
 	iks_insert_attrib(x, "mechanism", "PLAIN");
 	snprintf(s, len, "%c%s%c%s", 0, username, 0, pass);
-	ast_base64encode(base64, (const unsigned char *) s, len, (len + 2) * 4 / 3);
+
+	/* exclude the NULL training byte from the base64 encoding operation
+	   as some XMPP servers will refuse it.
+	   The format for authentication is [authzid]\0authcid\0password
+	   not [authzid]\0authcid\0password\0 */
+	ast_base64encode(base64, (const unsigned char *) s, len - 1, (len + 2) * 4 / 3);
 	iks_insert_cdata(x, base64, 0);
 	ast_aji_send(client, x);
 	iks_delete(x);




More information about the asterisk-commits mailing list