Hello everybody!
I'm trying to create a small SIP client in Visual Studio. I've managed to send a REGISTER message from the client pc to the AsteriskNOW PBX and receive the "401 Unauthorized" back with the WWW-Authenticate line. But now , I don't understand how to compute the MD5 response to the server... there are several parameters, and I cannot find anything on internet. the situation is the following:
DEVICES ADDRESSES:
IP PBX AsteriskNOW: 192.168.1.37
PC that sends the REGISTER message; 192.168.1.104
SIP account username: 117
SIP account password: abcd1234
REGISTER message
REGISTER sip:192.168.1.37 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.104:5060;branch=z9hG4bK213760691;rport
From: <sip:117@192.168.1.37>;tag=1270517038
To: <sip:117@192.168.1.37>
Call-ID: 1808066864-5060-1@BJC.BGI.B.D
CSeq: 2001 REGISTER
Contact: <sip:117@192.168.1.104:5060>;reg-id=1;
+sip.instance="<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
Max-Forwards: 70
User-Agent: Grandstream GXP1165 1.0.6.7
Supported: path
Expires: 3600
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER,
UPDATE, MESSAGE
Content-Length: 0
of course, at the line
+sip.instance="<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
there's the PC,s Network adapter MAC, instead of "AABBCCDDEEFF".
PBX Response
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP
192.168.1.104:5060;rport=5060;received=192.168.1.104;branch=z9hG4bK213760691
Call-ID: 1808066864-5060-1@BJC.BGI.B.D
From: <sip:117@192.168.1.37>;tag=1270517038
To: <sip:117@192.168.1.37>;tag=z9hG4bK2137606914
CSeq: 2001 REGISTER
WWW-Authenticate: Digest
realm="asterisk",nonce="1428402653/99967d603c38695f1c328332db91a43b",
opaque="416e7e1767513798",algorithm=md5,qop="auth"
Server: FPBX-AsteriskNOW-12.0.43(13.0.1)
Content-Length: 0
Now, how can i compute the MD5 response to the server, and what should I add in the new REGISTER message?
I've searched a lot on the internet but all i found was a lot of different examples with lots of different parameters, it's a mess!
Thank you