I'm impelementing SIP Digest authentication. Here's my 401 response from server.
SIP/2.0 401 Unauthorized
Call-ID: ed1c36aedb36da07d8d2cfe6b0126521@0:0:0:0:0:0:0:0
CSeq: 7 REGISTER
From: "myuser" <sip:myuser@sip2sip.info>;tag=c41616b8
To: "myuser" <sip:myuser@sip2sip.info>;tag=ac7e0189ab09b4fde10c77c8597b662a.5cbe
Via: SIP/2.0/UDP 172.22.162.100:5060;branch=z9hG4bK-333333-dd5444afbd4938fe01d9e1a47ccaf139
WWW-Authenticate: Digest realm="sip2sip.info", nonce="4d417ba7bb1906c1434ba9645b35d5a84d0e71ad"
Server: SIP Thor on OpenSIPS XS 1.4.5
Content-Length: 0
According to RFC 2617 the code to construct digest response should look like this (in Groovy)
def md5(user, realm, pass, method, String uri, nonce) {
def paramsDump = """md5() params
user: $user
realm: $realm
password: $pass
method: $method
uri: $uri
nonce: $nonce
"""
print paramsDump
def A1 = DigestUtils.md5Hex ("$user:$realm:$pass")
def A2 = DigestUtils.md5Hex ("$method:$uri")
def left = DigestUtils.md5Hex (A1)
def right = DigestUtils.md5Hex (A2)
DigestUtils.md5Hex ("$left:$nonce:$right")
}
md5 ('myuser',
'sip2sip.info',
'mypass',
'REGISTER',
'sip:sip2sip.info',
'4d417ba7bb1开发者_如何学Go906c1434ba9645b35d5a84d0e71ad')
For some reason it yields the value that differs from the one I expect (I know the predefined values that should work for my account - I've done some traffic sniffing of SIP Communicator application). DigestUtils type comes from Apache Codec. Any ideas?
I don't understand why you create the left and right like that, wouldn't
def A1 = DigestUtils.md5Hex ("$user:$realm:$pass")
def A2 = DigestUtils.md5Hex ("$method:$uri")
DigestUtils.md5Hex ("$A1:$nonce:$A2")
be according to section 3.2.2.1?
But I just might be missing something...;)
精彩评论