注冊(十一)重注冊带有鉴权信息

REGISTERsip:ims1.fj.chinamobile.com SIP/2.0

Via: SIP/2.0/UDP192.168.11.87:5060;branch=z9hG4bK5b646731

From:<sip:+865939008849@ims1.fj.chinamobile.com>;tag=06d66c62

To: <sip:+865939008849@ims1.fj.chinamobile.com>

Contact:<sip:+865939008849@192.168.11.87:5060>

Call-ID: 13819050150002400a3601b8e8@192.168.11.87

CSeq: 149 REGISTER

Expires: 240

Max-Forwards: 70

Content-Length: 0

 

UACUAS发起注冊请求

 

SIP/2.0 401 Unauthorized

Via: SIP/2.0/UDP 192.168.11.87:5060;branch=z9hG4bK5b646731

To:<sip:+865939008849@ims1.fj.chinamobile.com>;tag=ztesipSJjIMIg8*1-1-16648*eic.1

From:<sip:+865939008849@ims1.fj.chinamobile.com>;tag=06d66c62

Call-ID: 13819050150002400a3601b8e8@192.168.11.87

CSeq: 149 REGISTER

Content-Length: 0

WWW-Authenticate: Digest realm="ims1.fj.chinamobile.com",domain="sip:scscf1.fj.chinamobile.com",nonce="*******",opaque="*******",stale=TRUE,algorithm=MD5,qop="auth"

 

UASUAC发送的注冊请求回复401,告诉UAC发起的注冊请求须要带上鉴权信息

 

REGISTER sip:ims1.fj.chinamobile.comSIP/2.0

Via: SIP/2.0/UDP192.168.11.87:5060;branch=z9hG4bK2a2c4a56

From:<sip:+865939008849@ims1.fj.chinamobile.com>;tag=06d66c62

To:<sip:+865939008849@ims1.fj.chinamobile.com>

Contact:<sip:+865939008849@192.168.11.87:5060>

Call-ID: 13819050150002400a3601b8e8@192.168.11.87

CSeq: 150 REGISTER

Authorization: Digest username="+865939008849@ims1.fj.chinamobile.com",realm="ims1.fj.chinamobile.com",nonce="********",uri="sip:ims1.fj.chinamobile.com",response="********",algorithm=MD5,opaque="*******",qop=auth,nc=00000001,cnonce="*******"

Expires: 240

Max-Forwards: 70

Content-Length: 0

 

UAC又一次向UAS发起带上鉴权信息的注冊请求

 

SIP/2.0 200 OK

Via: SIP/2.0/UDP 192.168.11.87:5060;branch=z9hG4bK2a2c4a56

To:<sip:+865939008849@ims1.fj.chinamobile.com>;tag=ztesipy6MzDRK7tCp5Be*1-1-16640*eid.1

From:<sip:+865939008849@ims1.fj.chinamobile.com>;tag=06d66c62

Call-ID: 13819050150002400a3601b8e8@192.168.11.87

CSeq: 150 REGISTER

Contact:<sip:+865939008849@192.168.11.87:5060>;expires=240

Date: Wed, 16 Oct 2013 06:36:58 GMT

Authentication-Info:nextnonce="**************",qop=auth,rspauth="******************",cnonce="************",nc=00000001

Content-Length: 0

 

UAS对新发起的注冊请求进行验证通过后。回复200 OK表示这次请求认证通过,而且带上下次认证时须要的鉴权信息(Authentication-Info头域带有下次认证的鉴权信息)。UAC在发起重注冊消息直接带上鉴权信息,因此就不要须要在发起鉴权挑战。

 

REGISTERsip:ims1.fj.chinamobile.com SIP/2.0

Via: SIP/2.0/UDP192.168.11.87:5060;branch=z9hG4bK1c4230a0

From:<sip:+865939008849@ims1.fj.chinamobile.com>;tag=00502455

To:<sip:+865939008849@ims1.fj.chinamobile.com>

Contact: <sip:+865939008849@192.168.11.87:5060>

Call-ID: 13819050150002400a3601b8e8@192.168.11.87

CSeq: 151 REGISTER

Authorization: Digest username="+865939008849@ims1.fj.chinamobile.com",realm="ims1.fj.chinamobile.com",nonce="*******",uri="sip:ims1.fj.chinamobile.com",response="*****",algorithm=MD5,opaque="******",qop=auth,nc=00000002,cnonce="*******"

Expires: 240

Max-Forwards: 70

Content-Length: 0

 

UAC在认证快到期时,又一次发起注冊请求来刷新注冊有效期。而且在该注冊请求中带上鉴权信息(该鉴权信息,在上次UASUAC回复的200 OKAuthentication-Info头域中携带)。因此不须要发起鉴权挑战。

 

SIP/2.0 200 OK

Via: SIP/2.0/UDP 192.168.11.87:5060;branch=z9hG4bK2a2c4a56

To:<sip:+865939008849@ims1.fj.chinamobile.com>;tag=ztesipy6MzDRK7tCp5Be*1-1-16640*eid.1

From:<sip:+865939008849@ims1.fj.chinamobile.com>;tag=06d66c62

Call-ID: 13819050150002400a3601b8e8@192.168.11.87

CSeq: 150 REGISTER

Contact:<sip:+865939008849@192.168.11.87:5060>;expires=240

Date: Wed, 16 Oct 2013 06:36:58 GMT

Authentication-Info:nextnonce="************",qop=auth,rspauth="************",cnonce="**************",nc=00000002

Content-Length: 0

 

重注冊消息简要描写叙述:

1UAC向server发送注冊消息,server端启用注冊鉴权业务。

server端向用户回复401挑战,须要UAC端带上鉴权信息。

2UAC端发起新的注冊事物。而且带上鉴权信息Authentication-Info

UASUAC用户信息进行合法性检測。

3UASUAC的信息检測通过,并且回200OK表示本次注冊成功。并且带上下次注冊须要的nonce信息,以及本次nc注冊的数值。

4UAC发起重注冊消息。而且在消息中带上鉴权信息(使用200OKnextnonce的值,对username及password进行加密运算,并将200OKnextnonce的值回写到注冊消息nonce值中)。

5UAS对注冊信息进行合法性检測。发现重注冊消息带有鉴权信息。对鉴权信息验证,鉴权通过后,回复200OK,而且带上下次验证的nonce信息,以及本次nc数值。具体信息參见RFC2617文档。

6UAC再次发起注冊请求时,反复4-6)的步骤。

原文地址:https://www.cnblogs.com/wzjhoutai/p/6949639.html