Hello.
Is possible use some module in kamailio to authenticate against a Asterisk Box for example?. What I need is to have a Sip Client Registered in Kamailio, but when this client is called I need to send the call to Asterisk which will ask for authentication (user/pass). Is possible to do this with kamailio?. If so, can someone give an example?
Thanks in advance,
Regards,
Ricardo Martinez.-
On 05/17/2010 04:10 PM, Ricardo Martinez wrote:
Is possible use some module in kamailio to authenticate against a Asterisk Box for example?. What I need is to have a Sip Client Registered in Kamailio, but when this client is called I need to send the call to Asterisk which will ask for authentication (user/pass). Is possible to do this with kamailio?. If so, can someone give an example?
http://www.kamailio.org/docs/modules/3.0.x/modules_k/uac.html#id2885303
Hello Alex. Thanks for your answer. I was reading the documentation, but I'm still not getting the idea on how to use it. Can you give me an example...
I'm sending the INVITE to the asterisk box.. the asterisk responds a "SIP/2.0 401 Unauthorized."
From where do I get the user/pass to authenticate the user?
Hope you can guide me here.
Thanks in advance Regards, Ricardo.-
-----Mensaje original----- De: sr-users-bounces@lists.sip-router.org [mailto:sr-users-bounces@lists.sip-router.org] En nombre de Alex Balashov Enviado el: lunes, 17 de mayo de 2010 16:13 Para: sr-users@lists.sip-router.org Asunto: Re: [SR-Users] Kamailio as a UAC
On 05/17/2010 04:10 PM, Ricardo Martinez wrote:
Is possible use some module in kamailio to authenticate against a Asterisk Box for example?. What I need is to have a Sip Client Registered in Kamailio, but when this client is called I need to send the call to Asterisk which will ask for authentication (user/pass). Is possible to do this with kamailio?. If so, can someone give an
example?
http://www.kamailio.org/docs/modules/3.0.x/modules_k/uac.html#id2885303
On 05/17/2010 06:30 PM, Ricardo Martinez wrote:
I'm sending the INVITE to the asterisk box.. the asterisk responds a "SIP/2.0 401 Unauthorized." From where do I get the user/pass to authenticate the user?
In your initial request route, arm a failure route and catch the 401 challenge:
route { ...
t_on_failure("FAILURE_HANDLE");
if(!t_relay()) sl_reply_error();
}
failure_route[FAILURE_HANDLE] {
if(t_is_cancelled()) exit;
if(t_check_status("401")) { uac_auth(); }
...
t_relay(); }
}
I'm using the exact same script.. I even have a log line in the uac_auth(). So is catching the 401. But Kamailio is not sending the new INVITE with the credentials.. What else I'm missing...??
I also have defined :
modparam("uac","credential","username:domain:password") modparam("uac","auth_realm_avp","$avp(i:10)") modparam("uac","auth_username_avp","$avp(i:11)") modparam("uac","auth_password_avp","$avp(i:12)")
This is the debug.. 10.0.0.207 : GW 10.0.0.212 : Kamailio 10.0.0.197 : Asterisk
U 10.0.0.207:5060 -> 10.0.0.212:5060 INVITE sip:5501234567@10.0.0.212 SIP/2.0. Via: SIP/2.0/UDP 10.0.0.207:5060;branch=z9hG4bKd24b5e47a416. From: sip:2408100@10.0.0.207;tag=d24b5e47a4. To: sip:5501234567@10.0.0.212. Call-ID: d291f24b-58b6-5e54-8047-0002a4005672@10.0.0.207. CSeq: 16 INVITE. Supported: timer, replaces. Min-SE: 1800. Date: Tue, 18 May 2010 13:10:42 GMT. User-Agent: AddPac AP2520 8.30V. Contact: sip:2408100@10.0.0.207. Accept: application/sdp. Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, UPDATE, REFER, NOTIFY, INFO. Content-Type: application/sdp. Content-Length: 286. Max-Forwards: 70. . v=0. o=2408100 1274188242 1274188242 IN IP4 10.0.0.207. s=AddPac Gateway SDP. c=IN IP4 10.0.0.207. t=1274188242 0. m=audio 23032 RTP/AVP 0 8 18 101. a=rtpmap:0 PCMU/8000. a=rtpmap:8 PCMA/8000. a=rtpmap:18 G729/8000. a=rtpmap:101 telephone-event/8000. a=fmtp:101 0-15. a=ptime:20.
U 10.0.0.212:5060 -> 10.0.0.207:5060 SIP/2.0 100 trying -- your call is important to us. Via: SIP/2.0/UDP 10.0.0.207:5060;branch=z9hG4bKd24b5e47a416. From: sip:2408100@10.0.0.207;tag=d24b5e47a4. To: sip:5501234567@10.0.0.212. Call-ID: d291f24b-58b6-5e54-8047-0002a4005672@10.0.0.207. CSeq: 16 INVITE. Server: kamailio (3.0.1 (i386/linux)). Content-Length: 0. .
U 10.0.0.212:5060 -> 10.0.0.197:5060 INVITE sip:5501234567@10.0.0.197 SIP/2.0. Record-Route: sip:10.0.0.212;lr=on;ftag=d24b5e47a4;did=c3a.e176f9e4. Via: SIP/2.0/UDP 10.0.0.212;branch=z9hG4bK8a9d.47d682e.0. Via: SIP/2.0/UDP 10.0.0.207:5060;branch=z9hG4bKd24b5e47a416. From: sip:2408100@10.0.0.207;tag=d24b5e47a4. To: sip:5501234567@10.0.0.212. Call-ID: d291f24b-58b6-5e54-8047-0002a4005672@10.0.0.207. CSeq: 16 INVITE. Supported: timer, replaces. Min-SE: 1800. Date: Tue, 18 May 2010 13:10:42 GMT. User-Agent: AddPac AP2520 8.30V. Contact: sip:2408100@10.0.0.207. Accept: application/sdp. Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, UPDATE, REFER, NOTIFY, INFO. Content-Type: application/sdp. Content-Length: 286. Max-Forwards: 69. P-hint: outbound->inbound . . v=0. o=2408100 1274188242 1274188242 IN IP4 10.0.0.207. s=AddPac Gateway SDP. c=IN IP4 10.0.0.207. t=1274188242 0. m=audio 23032 RTP/AVP 0 8 18 101. a=rtpmap:0 PCMU/8000. a=rtpmap:8 PCMA/8000. a=rtpmap:18 G729/8000. a=rtpmap:101 telephone-event/8000. a=fmtp:101 0-15. a=ptime:20.
U 10.0.0.197:5060 -> 10.0.0.212:5060 SIP/2.0 401 Unauthorized. Via: SIP/2.0/UDP 10.0.0.212;branch=z9hG4bK8a9d.47d682e.0;received=10.0.0.212. Via: SIP/2.0/UDP 10.0.0.207:5060;branch=z9hG4bKd24b5e47a416. From: sip:2408100@10.0.0.207;tag=d24b5e47a4. To: sip:5501234567@10.0.0.212;tag=as6f2d46d3. Call-ID: d291f24b-58b6-5e54-8047-0002a4005672@10.0.0.207. CSeq: 16 INVITE. Server: Asterisk PBX 1.6.1.19. Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO. Supported: replaces, timer. WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="66243944". Content-Length: 0. .
U 10.0.0.212:5060 -> 10.0.0.197:5060 ACK sip:5501234567@10.0.0.197 SIP/2.0. Via: SIP/2.0/UDP 10.0.0.212;branch=z9hG4bK8a9d.47d682e.0. From: sip:2408100@10.0.0.207;tag=d24b5e47a4. To: sip:5501234567@10.0.0.212;tag=as6f2d46d3. Call-ID: d291f24b-58b6-5e54-8047-0002a4005672@10.0.0.207. CSeq: 16 ACK. Content-Length: 0. Max-Forwards: 69. .
U 10.0.0.212:5060 -> 10.0.0.207:5060 SIP/2.0 401 Unauthorized. Via: SIP/2.0/UDP 10.0.0.207:5060;branch=z9hG4bKd24b5e47a416. From: sip:2408100@10.0.0.207;tag=d24b5e47a4. To: sip:5501234567@10.0.0.212;tag=as6f2d46d3. Call-ID: d291f24b-58b6-5e54-8047-0002a4005672@10.0.0.207. CSeq: 16 INVITE. Server: Asterisk PBX 1.6.1.19. Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO. Supported: replaces, timer. WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="66243944". Content-Length: 0. .
U 10.0.0.207:5060 -> 10.0.0.212:5060 ACK sip:5501234567@10.0.0.212 SIP/2.0. Via: SIP/2.0/UDP 10.0.0.207:5060;branch=z9hG4bKd24b5e47a416. From: sip:2408100@10.0.0.207;tag=d24b5e47a4. To: sip:5501234567@10.0.0.212;tag=as6f2d46d3. Call-ID: d291f24b-58b6-5e54-8047-0002a4005672@10.0.0.207. CSeq: 16 ACK. Content-Length: 0. Max-Forwards: 70. .
Ricardo.-