Hello,
I’m new with Asterisk 20, in my other Asterisk (an older version -16-) I used chan_sip, but now it’s deprecated, and must use pjsip.
It’s a fresh Asterisk 20 installation, and I want to use a softphone (Jami) to use an extension, but when I try to register, I get the 401 Unautorized error:
<--- Received SIP request (549 bytes) from UDP:172.28.12.101:5060 --->
REGISTER sip:172.28.12.58 SIP/2.0
Via: SIP/2.0/UDP 172.28.12.101:5060;rport;branch=z9hG4bKPj7a3a686d-4370-4268-ab37-40efa277f231
Max-Forwards: 70
From: "SIP" <sip:1001@172.28.12.58>;tag=bc2bfad0-3e32-41e6-a416-52d1718a1206
To: "SIP" <sip:1001@172.28.12.58>
Call-ID: e2be94e6-7ca5-4f5f-b098-7459741bab0f
CSeq: 6733 REGISTER
User-Agent: Ring Daemon/7.4.0
Contact: "SIP" <sip:1001@172.28.12.101:5060>
Expires: 60
Allow: PRACK, SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, OPTIONS, MESSAGE, PUBLISH
Content-Length: 0
<--- Transmitting SIP response (578 bytes) to UDP:172.28.12.101:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 172.28.12.101:5060;rport=5060;received=172.28.12.101;branch=z9hG4bKPj7a3a686d-4370-4268-ab37-40efa277f231
Call-ID: e2be94e6-7ca5-4f5f-b098-7459741bab0f
From: "SIP" <sip:1001@172.28.12.58>;tag=bc2bfad0-3e32-41e6-a416-52d1718a1206
To: "SIP" <sip:1001@172.28.12.58>;tag=z9hG4bKPj7a3a686d-4370-4268-ab37-40efa277f231
CSeq: 6733 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1675534035/d98a907ccbd6fb5670d7f3153b8649dd",opaque="0402ac6424faa2df",algorithm=MD5,qop="auth"
Server: Asterisk PBX 20.1.0
Content-Length: 0
<--- Received SIP request (840 bytes) from UDP:172.28.12.101:5060 --->
REGISTER sip:172.28.12.58 SIP/2.0
Via: SIP/2.0/UDP 172.28.12.101:5060;rport;branch=z9hG4bKPjd0a2e826-ced7-4b0a-87d3-b3f02c15c4ba
Max-Forwards: 70
From: "SIP" <sip:1001@172.28.12.58>;tag=bc2bfad0-3e32-41e6-a416-52d1718a1206
To: "SIP" <sip:1001@172.28.12.58>
Call-ID: e2be94e6-7ca5-4f5f-b098-7459741bab0f
CSeq: 6734 REGISTER
User-Agent: Ring Daemon/7.4.0
Contact: "SIP" <sip:1001@172.28.12.101:5060>
Expires: 60
Allow: PRACK, SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, OPTIONS, MESSAGE, PUBLISH
Authorization: Digest username="1001", realm="asterisk", nonce="1675534035/d98a907ccbd6fb5670d7f3153b8649dd", uri="sip:172.28.12.58", response="5de7628d15bd68ed9ba0ebe8be3553b1", algorithm=MD5, cnonce="5c9c8f33-dd6d-4346-9080-c4eaef336ddc", opaque="0402ac6424faa2df", qop=auth, nc=00000001
Content-Length: 0
[Feb 4 19:07:15] NOTICE[593]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '"SIP" <sip:1001@172.28.12.58>' failed for '172.28.12.101:5060' (callid: e2be94e6-7ca5-4f5f-b098-7459741bab0f) - Failed to authenticate
<--- Transmitting SIP response (578 bytes) to UDP:172.28.12.101:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 172.28.12.101:5060;rport=5060;received=172.28.12.101;branch=z9hG4bKPjd0a2e826-ced7-4b0a-87d3-b3f02c15c4ba
Call-ID: e2be94e6-7ca5-4f5f-b098-7459741bab0f
From: "SIP" <sip:1001@172.28.12.58>;tag=bc2bfad0-3e32-41e6-a416-52d1718a1206
To: "SIP" <sip:1001@172.28.12.58>;tag=z9hG4bKPjd0a2e826-ced7-4b0a-87d3-b3f02c15c4ba
CSeq: 6734 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1675534035/d98a907ccbd6fb5670d7f3153b8649dd",opaque="5b08d90e7005fa40",algorithm=MD5,qop="auth"
Server: Asterisk PBX 20.1.0
Content-Length: 0
I only add to the pjsip.conf file:
;=============TEMPLATES TEST===================
[endpoint-basic](!)
type=endpoint
context=extensions
;transport=transport-udp
disallow=all
allow=all
[auth-userpass](!)
type=auth
auth_type=userpass
[aor-single-reg](!)
type=aor
max_contacts=1
;=============TEST===================
[1001](endpoint-basic)
auth=1001
aors=1001
[1001](auth-userpass)
password=1001
username=1001
[1001](aor-single-reg)
I put the username (1001) and the password (1001) in the softphone, but I don’t understand why is unauthorized. It’s strange to see in the logs “algorithm=MD5”, but I’m reading the official documentation and don’t see nothing about to hash the password.
I tried too with the pjsip examples with same result…
I have Asterisk 20 in a fresh vm (VirtualBox), first connected to a NAT network, but now directly to bridge.
I’m a noob with pjsip, but after read the wiki (too the migrating from SIP to PJSIP) i’m totally stucked.
Someone can guide me about my error (i’m sure that’s trivial, but I don’t find it).
Regards