[Asterisk-Users] sip registration problems

Juha Heinanen jh at lohi.eng.song.fi
Sat Apr 12 01:02:58 MST 2003


Mark Spencer writes:

 > The use of register => user:pass at host/contact should be sufficient.  You
 > have the three pieces of information..  the user that goes in "From" and
 > "To", the password (we'll authenticate with the username they supply us,
 > we really don't care -- or shouldn't -- which username we think we're
 > using) and the part to go in the contact.

that is not correct.  the sip ua needs to know its authorization
username.  when asterisk tries to register like this:

U 2003/04/12 10:41:07.253204 195.10.149.20:5060 -> 62.236.249.50:5060
REGISTER sip:62.236.249.50 SIP/2.0.
Via: SIP/2.0/UDP 195.10.149.20:5060;branch=z9hG4bK34feff73.
From: <sip:+358333983900 at sip.song.fi>;tag=as1395be3e.
To: <sip:+358333983900 at sip.song.fi>;tag=as1395be3e.
Call-ID: 744593ce4e5621a264e272401de781a9 at 195.10.149.20.
CSeq: 102 REGISTER.
User-Agent: Asterisk PBX.
Expires: 120.
Contact: <sip:s at 195.10.149.20>.
Event: registration.
Content-length: 0.

it gets back 401:

U 2003/04/12 10:41:07.253432 62.236.249.50:5060 -> 195.10.149.20:5060
SIP/2.0 401 Unauthorized.
Via: SIP/2.0/UDP 195.10.149.20:5060;branch=z9hG4bK34feff73.
From: <sip:+358333983900 at sip.song.fi>;tag=as1395be3e.
To: <sip:+358333983900 at sip.song.fi>;tag=as1395be3e.
Call-ID: 744593ce4e5621a264e272401de781a9 at 195.10.149.20.
CSeq: 102 REGISTER.
WWW-Authenticate: Digest realm="sip.song.fi", nonce="3e97c43f00000000f408a072fa\c19188f1d87bbae4387351", qop="auth".
Server: Song SIP Router.
Content-Length: 0.

as you see, 401 doesn't contain a username, only the realm.  asterisk
needs to know which username to use for that realm and insert it into
the username field of the authorization header in the next attempt.  now
it puts the uri username field there:

U 2003/04/12 10:41:07.281990 195.10.149.20:5060 -> 62.236.249.50:5060
REGISTER sip:62.236.249.50 SIP/2.0.
Via: SIP/2.0/UDP 195.10.149.20:5060;branch=z9hG4bK34feff73.
From: <sip:+358333983900 at sip.song.fi>;tag=as1395be3e.
To: <sip:+358333983900 at sip.song.fi>;tag=as1395be3e.
Call-ID: 744593ce4e5621a264e272401de781a9 at 195.10.149.20.
CSeq: 103 REGISTER.
User-Agent: Asterisk PBX.
Authorization: Digest username="+358333983900", realm="sip.song.fi", algorithm=\"MD5", uri="sip:+358333983900 at 62.236.249.50", nonce="3e97c43f00000000f408a072fa\c19188f1d87bbae4387351", response="d5b1839cec02f773947ba45ee17a2bbf".
Expires: 120.
Contact: <sip:s at 195.10.149.20>.
Event: registration.
Content-length: 0.

which causes the register to fail.  so i return to my suggestion to make
register config look like this:

uri-to-be registered:authorization-username:password/contact

plus a new general entry for outbound proxy at least for as long as
naptr/srv stuff has not been implemented.

i have a couple of other issues regarding asterisk's register request:

1) request uri should also contain the domain name (sip.song.fi), not
   the ip address (62.236.249.50).

2) to tag should not be included

3) uri field in the authorization header should contain the request uri,
   not the uri to be registered, i.e., sip:sip.song.fi in the above
   example.

4) when asterisk gets another 401 back, it keeps on trying forever and
   thus causing big stress to the network and the proxy.  if
   registration fails, asterisk should wait for a while before trying
   again.

draft-ietf-sipping-basic-call-flows-02.txt is a good source for more
examples.

-- juha




More information about the asterisk-users mailing list