SIP 401 Unauthorized

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi :),


I'm having a problem using pjlib. I'm just trying to figure out the basic example of the website but i get some SIP problems.
Please note that my sip configuration is OK as I use it with xLite and it works perfectly.


What I observed comparing the packets from pjsip and xLite is the following.


xLite and pjsip both send a REGISTER packet with the same content.
The server answers 100 TRYING and 401 UNAUTHORIZED.


Then xLite includes an authentication field to the previous REGISTER packet and send it (CSeq is incremented also). So the SIP protocol continues well.
Contrary to pjsip which resends the exact same packet (even with the same CSeq number). So the server obviously answers the same error and it continues indefinitely until I got the message from pjsua_acc.c @ regc_cb() : PJ_LOG(4, (THIS_FILE, "SIP registration updated status=%d", param->code));.


I have seen the following code is never called (pjsua_acc.c @ pjsua_acc_set_registration()):


if (0 && status == PJ_SUCCESS && pjsua_var.acc[acc_id].cred_cnt) {
pjsua_acc *acc = &pjsua_var.acc[acc_id];
pjsip_authorization_hdr *h;
char *uri;
	    int d;

	    uri = (char*) pj_pool_alloc(tdata->pool, acc->cfg.reg_uri.slen+10);
	    d = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, tdata->msg->line.req.uri,
				uri, acc->cfg.reg_uri.slen+10);
	    pj_assert(d > 0);

	    h = pjsip_authorization_hdr_create(tdata->pool);
	    h->scheme = pj_str("Digest");
	    h->credential.digest.username = acc->cred[0].username;
	    h->credential.digest.realm = acc->srv_domain;
	    h->credential.digest.uri = pj_str(uri);
	    h->credential.digest.algorithm = pj_str("md5");

	    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)h);
	}


Indeed status is always 0 and cred_cnt is 1.


I think the problem might be here because apparently this code sets the authentication field in the packet.


Thank you for your help ;)




 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20120302/c01bbf04/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux