pfichtner / SipDoorbell

ESP8266 Firmware that initiates calls to SIP numbers, can react on hardware button as well to 433 MHz signals
MIT License
11 stars 1 forks source link

SIP Unauthorized #106

Open rkorn86 opened 1 month ago

rkorn86 commented 1 month ago

I am running a local asterisk and all my SIP clients are working great, except for this one. I never see any SIP authentication in my server log, but only an authorized message, when the ESP is trying to initiate a call.

I thought the configuration should be straight forward, but it seems to rely on some "fritzbox" specific stuff?!

pfichtner commented 1 month ago

The library used is very minimalistic, it sends an invite w/o auth and does an invite with auth after receiving 401 Unauthorized. I did a rewrite, could you check if this works? https://github.com/pfichtner/jsipdialer Both implementations do an invite, I am not sure if they should do a register first. If jsipdialer works for you I think it's an issue in the challenge/response process.

rkorn86 commented 1 month ago

https://github.com/pfichtner/jsipdialer works as expected:

Aug 07, 2024 11:42:17 PM com.github.pfichtner.jsipdialer.UdpConnection send
INFO: Sending: INVITE sip:100@192.168.0.8 SIP/2.0
CSeq: 1 INVITE
Call-ID: 1020782030@192.168.0.22
From: "Klingel <5>" <sip:klingel@192.168.0.8>;tag=0864381819
Via: SIP/2.0/UDP 192.168.0.22:44394;rport=44394
To: <sip:100@192.168.0.8>
Contact: "klingel" <sip:klingel@192.168.0.8:44394;transport=udp>
Content-Length: 0

Aug 07, 2024 11:42:17 PM com.github.pfichtner.jsipdialer.UdpConnection receive
INFO: Response from SIP Server: SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.0.22:44394;rport=44394;received=192.168.0.22
Call-ID: 1020782030@192.168.0.22
From: "Klingel <5>" <sip:klingel@192.168.0.8>;tag=0864381819
To: <sip:100@192.168.0.8>
CSeq: 1 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="XXXX",opaque="XXXX",algorithm=MD5,qop="auth"
Server: asterisk
Content-Length:  0

Aug 07, 2024 11:42:17 PM com.github.pfichtner.jsipdialer.UdpConnection send
INFO: Sending: INVITE sip:100@192.168.0.8 SIP/2.0
CSeq: 2 INVITE
Call-ID: 1020782030@192.168.0.22
From: "Klingel <5>" <sip:klingel@192.168.0.8>;tag=0864381819
Via: SIP/2.0/UDP 192.168.0.22:44394;rport=44394
To: <sip:100@192.168.0.8>
Contact: "klingel" <sip:klingel@192.168.0.8:44394;transport=udp>
Authorization: Digest username="klingel", realm="asterisk", nonce="XXXX", uri="sip:100@192.168.0.8", response="XXXX", algorithm="MD5"
Content-Length: 0
....
pfichtner commented 1 month ago

https://github.com/pfichtner/jsipdialer works as expected: [...]

Ok, thanks for checking this. Any chance to capture the packets using wireshark or tcpdump? Is the ESP is connected to a PC it writes some debug messages to the serial console (115200 8N1). Could you please take a look if there something that could help? If not I could add some more debug messages to possibly locate the problem that way.

pfichtner commented 1 month ago

Could you please try firmware.bin of https://github.com/pfichtner/SipDoorbell/actions/runs/10341003285, I enabled debug there

rkorn86 commented 2 weeks ago

Sorry, I have no (unused) device anymore since I flashed my ESP with tasmota and use https://github.com/arnonym/ha-plugins for my door bell now.

pfichtner commented 2 weeks ago

Sorry, I have no (unused) device anymore since I flashed my ESP with tasmota and use https://github.com/arnonym/ha-plugins for my door bell now.

Yeah, the idea of this project is, that this will work standalone, so that the doorbell can init a call without additional components. I started to write an integration test where I tried to fire up an asterisk in a docker container with the needed settings but because asterisk is not that easy to configure I couldn't get it work.

I leave this issue open until I find the time to configure asterisk with that minimal setup so that I can test if SipDoorbell works with asterisk as well.