Hello,

it is asterisk that asks second time - kamailio is verifying the auth ok, then forwards to asterisk which asks again for authentication. Read the notes from the Asterisk Database section in the tuorial:

http://kb.asipto.com/asterisk:realtime:kamailio-4.0.x-asterisk-11.3.0-astdb#asterisk_database

You should not set the secret in asterisk table, but use another column to store the password.

Cheers,
Daniel

On 23/07/14 21:52, proLogika wrote:
Hello,
I am using Kamailio as SIP register with asterisk integration describe from hire: 
http://kb.asipto.com/asterisk:realtime:kamailio-4.0.x-asterisk-11.3.0-astdb .
asterisk is listen on public ip: 2.3.4.5:5060
kamailio is listen on public ip: 1.2.3.4:5060

everything is working well except some software VoIP clients (like Yate) and CISCO phone like Cisco-CP7940G/8.0 and the new one from Cisco series. I’m testing now with Yate client and Cisco. They are register OK but when a call is made Kamailio is answer back with 407 Proxy Authentication Required. When I register Yate or Cisco to asterisk directly the call is passing normaly. I was trying to manipulate kamailio.cfg and more specifically the part: 

#!ifdef WITH_ASTERISK

                if (!auth_check("$fd", "sipusers", "1")) {

#!else

                if (!auth_check("$fd", "subscriber", "1")) {

#!endif

                        auth_challenge("$fd", "0");

                        exit;

 
If i commented out this part the call is passing, but I do not have auth anymore (everyone can register) 

Here is ngrep:

U 2014/07/23 19:17:08.108458 192.168.0.40:5060 -> 1.2.3.4:5060

INVITE sip:0896995837@1.2.3.4 SIP/2.0.

Max-Forwards: 20.

Via: SIP/2.0/UDP 192.168.0.40:5060;rport;branch=z9hG4bK1899510692.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>.

Call-ID: 931919626@1.2.3.4.

CSeq: 13 INVITE.

User-Agent: YATE/5.3.0.

Contact: <sip:10891@192.168.0.40:5060>.

Allow: ACK, INVITE, BYE, CANCEL, OPTIONS, INFO.

Content-Type: application/sdp.

Content-Length: 481.

.

v=0.

o=yate 1406132227 1406132227 IN IP4 192.168.0.40.

s=SIP Call.

c=IN IP4 192.168.0.40.

t=0 0.

m=audio 29696 RTP/AVP 0 8 11 98 97 102 103 104 105 106 101.

a=rtpmap:0 PCMU/8000.

a=rtpmap:8 PCMA/8000.

a=rtpmap:11 L16/8000.

a=rtpmap:98 iLBC/8000.

a=fmtp:98 mode=20.

a=rtpmap:97 iLBC/8000.

a=fmtp:97 mode=30.

a=rtpmap:102 SPEEX/8000.

a=rtpmap:103 SPEEX/16000.

a=rtpmap:104 SPEEX/32000.

a=rtpmap:105 iSAC/16000.

a=rtpmap:106 iSAC/32000.

a=rtpmap:101 telephone-event/8000.

a=ptime:30.



U 2014/07/23 19:17:08.108805 1.2.3.4:5060 -> 192.168.0.40:5060

SIP/2.0 407 Proxy Authentication Required.

Via: SIP/2.0/UDP 192.168.0.40:5060;rport=5060;branch=z9hG4bK1899510692.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>;tag=6be166fd53062bbc5b6dd79656b620cd.1950.

Call-ID: 931919626@1.2.3.4.

CSeq: 13 INVITE.

Proxy-Authenticate: Digest realm="1.2.3.4", nonce="U8/hMFPP4AR+N3A+ZccNiTw6rV9JTq1I".

Server: kamailio (4.0.6 (x86_64/linux)).

Content-Length: 0.

.



U 2014/07/23 19:17:08.128626 192.168.0.40:5060 -> 1.2.3.4:5060

ACK sip:0896995837@1.2.3.4 SIP/2.0.

Via: SIP/2.0/UDP 192.168.0.40:5060;rport;branch=z9hG4bK1899510692.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>;tag=6be166fd53062bbc5b6dd79656b620cd.1950.

Call-ID: 931919626@1.2.3.4.

CSeq: 13 ACK.

Max-Forwards: 20.

Contact: <sip:10891@192.168.0.40:5060>.

User-Agent: YATE/5.3.0.

Content-Length: 0.

.



U 2014/07/23 19:17:08.129076 192.168.0.40:5060 -> 1.2.3.4:5060

INVITE sip:0896995837@1.2.3.4 SIP/2.0.

Max-Forwards: 20.

Via: SIP/2.0/UDP 192.168.0.40:5060;rport;branch=z9hG4bK302777344.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>.

Call-ID: 931919626@1.2.3.4.

User-Agent: YATE/5.3.0.

Contact: <sip:10891@192.168.0.40:5060>.

Allow: ACK, INVITE, BYE, CANCEL, OPTIONS, INFO.

CSeq: 14 INVITE.

Proxy-Authorization: Digest username="10891", realm="1.2.3.4", nonce="U8/hMFPP4AR+N3A+ZccNiTw6rV9JTq1I", uri="sip:0896995837@1.2.3.4", response="b96eebd48b3734e1d018a970fa3a2283", algorithm=MD5.

Content-Type: application/sdp.

Content-Length: 481.

.

v=0.

o=yate 1406132227 1406132227 IN IP4 192.168.0.40.

s=SIP Call.

c=IN IP4 192.168.0.40.

t=0 0.

m=audio 29696 RTP/AVP 0 8 11 98 97 102 103 104 105 106 101.

a=rtpmap:0 PCMU/8000.

a=rtpmap:8 PCMA/8000.

a=rtpmap:11 L16/8000.

a=rtpmap:98 iLBC/8000.

a=fmtp:98 mode=20.

a=rtpmap:97 iLBC/8000.

a=fmtp:97 mode=30.

a=rtpmap:102 SPEEX/8000.

a=rtpmap:103 SPEEX/16000.

a=rtpmap:104 SPEEX/32000.

a=rtpmap:105 iSAC/16000.

a=rtpmap:106 iSAC/32000.

a=rtpmap:101 telephone-event/8000.

a=ptime:30.



U 2014/07/23 19:17:08.129622 1.2.3.4:5060 -> 192.168.0.40:5060

SIP/2.0 100 trying -- your call is important to us.

Via: SIP/2.0/UDP 192.168.0.40:5060;rport=5060;branch=z9hG4bK302777344.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>.

Call-ID: 931919626@1.2.3.4.

CSeq: 14 INVITE.

Server: kamailio (4.0.6 (x86_64/linux)).

Content-Length: 0.

.



U 2014/07/23 19:17:08.130107 1.2.3.4:5060 -> 2.3.4.5:5060

INVITE sip:0896995837@1.2.3.4 SIP/2.0.

Record-Route: <sip:1.2.3.4;lr=on;ftag=838449717;nat=yes>.

Max-Forwards: 16.

Via: SIP/2.0/UDP 1.2.3.4;branch=z9hG4bK73f1.c43865a50d7a342a46dcebf824782de0.0.

Via: SIP/2.0/UDP 192.168.0.40:5060;rport=5060;branch=z9hG4bK302777344.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>.

Call-ID: 931919626@1.2.3.4.

User-Agent: YATE/5.3.0.

Contact: <sip:10891@192.168.0.40:5060>.

Allow: ACK, INVITE, BYE, CANCEL, OPTIONS, INFO.

CSeq: 14 INVITE.

Content-Type: application/sdp.

Content-Length: 499.

.

v=0.

o=yate 1406132227 1406132227 IN IP4 1.2.3.4.

s=SIP Call.

c=IN IP4 1.2.3.4.

t=0 0.

m=audio 21888 RTP/AVP 0 8 11 98 97 102 103 104 105 106 101.

a=rtpmap:0 PCMU/8000.

a=rtpmap:8 PCMA/8000.

a=rtpmap:11 L16/8000.

a=rtpmap:98 iLBC/8000.

a=fmtp:98 mode=20.

a=rtpmap:97 iLBC/8000.

a=fmtp:97 mode=30.

a=rtpmap:102 SPEEX/8000.

a=rtpmap:103 SPEEX/16000.

a=rtpmap:104 SPEEX/32000.

a=rtpmap:105 iSAC/16000.

a=rtpmap:106 iSAC/32000.

a=rtpmap:101 telephone-event/8000.

a=ptime:30.

a=nortpproxy:yes.



U 2014/07/23 19:17:08.130593 2.3.4.5:5060 -> 1.2.3.4:5060

SIP/2.0 401 Unauthorized.

Via: SIP/2.0/UDP 1.2.3.4;branch=z9hG4bK73f1.c43865a50d7a342a46dcebf824782de0.0;received=1.2.3.4;rport=5060.

Via: SIP/2.0/UDP 192.168.0.40:5060;rport=5060;branch=z9hG4bK302777344.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>;tag=as31a58bb2.

Call-ID: 931919626@1.2.3.4.

CSeq: 14 INVITE.

Server: Asterisk PBX 1.8.29.0.

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE.

Supported: replaces, timer.

WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="7531867c".

Content-Length: 0.

.



U 2014/07/23 19:17:08.130770 1.2.3.4:5060 -> 2.3.4.5:5060

ACK sip:0896995837@1.2.3.4 SIP/2.0.

Max-Forwards: 16.

Via: SIP/2.0/UDP 1.2.3.4;branch=z9hG4bK73f1.c43865a50d7a342a46dcebf824782de0.0.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>;tag=as31a58bb2.

Call-ID: 931919626@1.2.3.4.

CSeq: 14 ACK.

Content-Length: 0.

.



U 2014/07/23 19:17:08.131361 1.2.3.4:5060 -> 192.168.0.40:5060

SIP/2.0 401 Unauthorized.

Via: SIP/2.0/UDP 192.168.0.40:5060;rport=5060;branch=z9hG4bK302777344.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>;tag=as31a58bb2.

Call-ID: 931919626@1.2.3.4.

CSeq: 14 INVITE.

Server: Asterisk PBX 1.8.29.0.

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE.

Supported: replaces, timer.

WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="7531867c".

Content-Length: 0.

.



U 2014/07/23 19:17:08.149847 192.168.0.40:5060 -> 1.2.3.4:5060

ACK sip:0896995837@1.2.3.4 SIP/2.0.

Via: SIP/2.0/UDP 192.168.0.40:5060;rport;branch=z9hG4bK302777344.

From: <sip:10891@1.2.3.4>;tag=838449717.

To: <sip:0896995837@1.2.3.4>;tag=as31a58bb2.

Call-ID: 931919626@1.2.3.4.

CSeq: 14 ACK.

Max-Forwards: 20.

Contact: <sip:10891@192.168.0.40:5060>.

Proxy-Authorization: Digest username="10891", realm="1.2.3.4", nonce="U8/hMFPP4AR+N3A+ZccNiTw6rV9JTq1I", uri="sip:0896995837@1.2.3.4", response="b96eebd48b3734e1d018a970fa3a2283", algorithm=MD5.

User-Agent: YATE/5.3.0.

Content-Length: 0.

— 

And kamailio.cfg attached:
 
proLogika
Sent with Airmail


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda