Register failed. Failed to authenticate (401) an extension

Hello,
I tried now with my hardphone (Yealink T22P), and with the same configuration works (there are some errors with extensions *98 and *99 because don’t exist in this Asterisk context):

<--- Received SIP request (548 bytes) from UDP:172.28.12.121:5062 --->
REGISTER sip:172.28.12.58 SIP/2.0
Via: SIP/2.0/UDP 172.28.12.121:5062;branch=z9hG4bK2965467645
From: "Pruebas" <sip:1001@172.28.12.58>;tag=1134127850
To: "Pruebas" <sip:1001@172.28.12.58>
Call-ID: 114966780@172.28.12.121
CSeq: 1 REGISTER
Contact: <sip:1001@172.28.12.121:5062>
Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE
Max-Forwards: 70
User-Agent: Yealink SIP-T22P 7.73.0.50
Expires: 3600
Allow-Events: talk,hold,conference,refer,check-sync
Content-Length: 0


<--- Transmitting SIP response (488 bytes) to UDP:172.28.12.121:5062 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 172.28.12.121:5062;rport=5062;received=172.28.12.121;branch=z9hG4bK2965467645
Call-ID: 114966780@172.28.12.121
From: "Pruebas" <sip:1001@172.28.12.58>;tag=1134127850
To: "Pruebas" <sip:1001@172.28.12.58>;tag=z9hG4bK2965467645
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1675595372/d90f425554916379b9a857029cc85c31",opaque="423e41bc3f4b5398",algorithm=MD5,qop="auth"
Server: Asterisk PBX 20.1.0
Content-Length:  0


<--- Received SIP request (810 bytes) from UDP:172.28.12.121:5062 --->
REGISTER sip:172.28.12.58 SIP/2.0
Via: SIP/2.0/UDP 172.28.12.121:5062;branch=z9hG4bK100776375
From: "Pruebas" <sip:1001@172.28.12.58>;tag=1134127850
To: "Pruebas" <sip:1001@172.28.12.58>
Call-ID: 114966780@172.28.12.121
CSeq: 2 REGISTER
Contact: <sip:1001@172.28.12.121:5062>
Authorization: Digest username="1001", realm="asterisk", nonce="1675595372/d90f425554916379b9a857029cc85c31", uri="sip:172.28.12.58", response="3a3f5a4ef70d665ed404ae05593efca6", algorithm=MD5, cnonce="0a4f113b", opaque="423e41bc3f4b5398", qop=auth, nc=00000001
Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE
Max-Forwards: 70
User-Agent: Yealink SIP-T22P 7.73.0.50
Expires: 3600
Allow-Events: talk,hold,conference,refer,check-sync
Content-Length: 0


    -- Added contact 'sip:1001@172.28.12.121:5062' to AOR '1001' with expiration of 3600 seconds
<--- Transmitting SIP response (435 bytes) to UDP:172.28.12.121:5062 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 172.28.12.121:5062;rport=5062;received=172.28.12.121;branch=z9hG4bK100776375
Call-ID: 114966780@172.28.12.121
From: "Pruebas" <sip:1001@172.28.12.58>;tag=1134127850
To: "Pruebas" <sip:1001@172.28.12.58>;tag=z9hG4bK100776375
CSeq: 2 REGISTER
Date: Sun, 05 Feb 2023 11:09:32 GMT
Contact: <sip:1001@172.28.12.121:5062>;expires=3599
Expires: 3600
Server: Asterisk PBX 20.1.0
Content-Length:  0


  == Endpoint 1001 is now Reachable
<--- Received SIP request (425 bytes) from UDP:172.28.12.121:5062 --->
SUBSCRIBE sip:*88@172.28.12.58 SIP/2.0
Via: SIP/2.0/UDP 172.28.12.121:5062;branch=z9hG4bK1213557915
From: "Pruebas" <sip:1001@172.28.12.58>;tag=4173360969
To: <sip:*88@172.28.12.58>
Call-ID: 670878740@172.28.12.121
CSeq: 1 SUBSCRIBE
Contact: <sip:1001@172.28.12.121:5062>
Accept: application/dialog-info+xml
Max-Forwards: 70
User-Agent: Yealink SIP-T22P 7.73.0.50
Expires: 1800
Event: dialog
Content-Length: 0


<--- Transmitting SIP response (478 bytes) to UDP:172.28.12.121:5062 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 172.28.12.121:5062;rport=5062;received=172.28.12.121;branch=z9hG4bK1213557915
Call-ID: 670878740@172.28.12.121
From: "Pruebas" <sip:1001@172.28.12.58>;tag=4173360969
To: <sip:*88@172.28.12.58>;tag=z9hG4bK1213557915
CSeq: 1 SUBSCRIBE
WWW-Authenticate: Digest realm="asterisk",nonce="1675595372/d90f425554916379b9a857029cc85c31",opaque="06ca0cbd7ab3d5d7",algorithm=MD5,qop="auth"
Server: Asterisk PBX 20.1.0
Content-Length:  0


<--- Received SIP request (691 bytes) from UDP:172.28.12.121:5062 --->
SUBSCRIBE sip:*88@172.28.12.58 SIP/2.0
Via: SIP/2.0/UDP 172.28.12.121:5062;branch=z9hG4bK742910469
From: "Pruebas" <sip:1001@172.28.12.58>;tag=4173360969
To: <sip:*88@172.28.12.58>
Call-ID: 670878740@172.28.12.121
CSeq: 2 SUBSCRIBE
Contact: <sip:1001@172.28.12.121:5062>
Authorization: Digest username="1001", realm="asterisk", nonce="1675595372/d90f425554916379b9a857029cc85c31", uri="sip:*88@172.28.12.58", response="d96afdad5c75f7b2ff073af63d511202", algorithm=MD5, cnonce="0a4f113b", opaque="06ca0cbd7ab3d5d7", qop=auth, nc=00000001
Accept: application/dialog-info+xml
Max-Forwards: 70
User-Agent: Yealink SIP-T22P 7.73.0.50
Expires: 1800
Event: dialog
Content-Length: 0


[Feb  5 12:09:32] NOTICE[61132]: res_pjsip_exten_state.c:429 new_subscribe: Endpoint '1001' state subscription failed: Extension '*88' does not exist in context 'extensions' or has no associated hint
<--- Transmitting SIP response (327 bytes) to UDP:172.28.12.121:5062 --->
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 172.28.12.121:5062;rport=5062;received=172.28.12.121;branch=z9hG4bK742910469
Call-ID: 670878740@172.28.12.121
From: "Pruebas" <sip:1001@172.28.12.58>;tag=4173360969
To: <sip:*88@172.28.12.58>;tag=z9hG4bK742910469
CSeq: 2 SUBSCRIBE
Server: Asterisk PBX 20.1.0
Content-Length:  0


<--- Received SIP request (426 bytes) from UDP:172.28.12.121:5062 --->
SUBSCRIBE sip:*98@172.28.12.58 SIP/2.0
Via: SIP/2.0/UDP 172.28.12.121:5062;branch=z9hG4bK3342579464
From: "Pruebas" <sip:1001@172.28.12.58>;tag=4046678955
To: <sip:*98@172.28.12.58>
Call-ID: 2421951770@172.28.12.121
CSeq: 1 SUBSCRIBE
Contact: <sip:1001@172.28.12.121:5062>
Accept: application/dialog-info+xml
Max-Forwards: 70
User-Agent: Yealink SIP-T22P 7.73.0.50
Expires: 1800
Event: dialog
Content-Length: 0


<--- Transmitting SIP response (479 bytes) to UDP:172.28.12.121:5062 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 172.28.12.121:5062;rport=5062;received=172.28.12.121;branch=z9hG4bK3342579464
Call-ID: 2421951770@172.28.12.121
From: "Pruebas" <sip:1001@172.28.12.58>;tag=4046678955
To: <sip:*98@172.28.12.58>;tag=z9hG4bK3342579464
CSeq: 1 SUBSCRIBE
WWW-Authenticate: Digest realm="asterisk",nonce="1675595373/e9a93c1210f61c200b67729514ed13e3",opaque="7e8558f116a615dd",algorithm=MD5,qop="auth"
Server: Asterisk PBX 20.1.0
Content-Length:  0


<--- Received SIP request (692 bytes) from UDP:172.28.12.121:5062 --->
SUBSCRIBE sip:*98@172.28.12.58 SIP/2.0
Via: SIP/2.0/UDP 172.28.12.121:5062;branch=z9hG4bK484043980
From: "Pruebas" <sip:1001@172.28.12.58>;tag=4046678955
To: <sip:*98@172.28.12.58>
Call-ID: 2421951770@172.28.12.121
CSeq: 2 SUBSCRIBE
Contact: <sip:1001@172.28.12.121:5062>
Authorization: Digest username="1001", realm="asterisk", nonce="1675595373/e9a93c1210f61c200b67729514ed13e3", uri="sip:*98@172.28.12.58", response="8f91263b9bd802ef9ff388cf18a83a58", algorithm=MD5, cnonce="0a4f113b", opaque="7e8558f116a615dd", qop=auth, nc=00000001
Accept: application/dialog-info+xml
Max-Forwards: 70
User-Agent: Yealink SIP-T22P 7.73.0.50
Expires: 1800
Event: dialog
Content-Length: 0


[Feb  5 12:09:33] NOTICE[61132]: res_pjsip_exten_state.c:429 new_subscribe: Endpoint '1001' state subscription failed: Extension '*98' does not exist in context 'extensions' or has no associated hint
<--- Transmitting SIP response (328 bytes) to UDP:172.28.12.121:5062 --->
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 172.28.12.121:5062;rport=5062;received=172.28.12.121;branch=z9hG4bK484043980
Call-ID: 2421951770@172.28.12.121
From: "Pruebas" <sip:1001@172.28.12.58>;tag=4046678955
To: <sip:*98@172.28.12.58>;tag=z9hG4bK484043980
CSeq: 2 SUBSCRIBE
Server: Asterisk PBX 20.1.0
Content-Length:  0

Then, the problem must be with the softphone: Jami.
As you can see, all security options are disabled (to remove complexity from connection testing).





imagen
But if I try with other softphone (as linphone or zoiper) I can’t register…
Regards

Edit:
I think I found the solution: As I run Asterisk in a virtualized system (VirtualBox), when I compile the sources, compiler optimize the binary files for the CPU, but as it’s virtualized, it fails. The solution is when I do the “make menuselect” unselect in “Compiler Flags” the option “BUILD NATIVE” (uncheck the option).
I read this solution from @jcolp in some threads as Asterisk 13.1 Startup Failed - Please Assist and PJSIP calling issues , but I tried to do this without success along some days. Now I started once again from a new fresh installation on Debian 11, and selecting this option, and it worked (at least can register the extensions). Maybe some files were not overwritten after recompile without the “BUILD NATIVE” option… Maybe developers can find some bug in the make files that prevent to overwrite some binaries.