From olli.attila@oatel.net Wed May 24 08:36:44 2017 From: Olli Attila To: sr-users@lists.kamailio.org Subject: Re: [SR-Users] Kamailio and XMLRPC commands with POST Date: Wed, 24 May 2017 09:36:28 +0300 Message-ID: <448f7ae1db29ce55f8f123b508cdb111@oatel.net> In-Reply-To: <64DB4831-A87D-41CE-8098-B2155C754B77@oatel.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0616206938==" --===============0616206938== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello, I tried to configure the same XMLRPC case to a RHEL7 platform with=20 kamailio 5.0.0 installed but Kamailio keeps sending me this after XMLRPC=20 POST: HTTP/1.1 200 OK Sia: SIP/2.0/TCP 10.40.6.127:49384 Content-Type: text/html Server: kamailio (5.0.0 (x86_64/linux)) Content-Length: 40 Wrong URL /RPC Any idea why the RHEL7 Kamailio installation does not work like the=20 Debian? I have enabled debug level 4 but I see no errors concearning this reply. The scenario which is working is configured on a Debian platform with=20 Kamailio 5.0.0. Cheers, --Olli Oma kirjoitti 2017-05-23 22:33: > Hello, >=20 > Thanks for the tip Daniel. I added this before the dispatch_rpc() and > other xmlrpc related stuff: >=20 > ... > if (!www_authorize(=E2=80=9Dsomedomain.local", "subscriber")) { > www_challenge(=E2=80=9Dsomedomain.local", "1"); > exit; > }; > =E2=80=A6 >=20 > Seems to work now with the correct username and password retrieved > from subscriber table: >=20 > After 200OK the dialplan gets reloaded in this example. >=20 > POST /RPC HTTP/1.1. > Accept: */*. > Host: 127.0.0.1:5060. > User-Agent: xmlrpcclient. > Content-Type: text/xml. > Content-Length: 0. >=20 >=20 > T 127.0.0.1:5060 -> 127.0.0.1:57265 [AP] > HTTP/1.1 401 Unauthorized. > Sia: SIP/2.0/TCP 127.0.0.1:57265. > WWW-Authenticate: Digest realm=3D=E2=80=9Dsomedomain.local", > nonce=3D"WSSNE1kki+cE7oCG5vjVrxI/BZRRfmOmXKecloA=3D", qop=3D"auth". > Content-Length: 0. >=20 >=20 > T 127.0.0.1:57265 -> 127.0.0.1:5060 [AP] > POST /RPC HTTP/1.1. > Authorization: Digest username=3D"testuser", realm=3D=E2=80=9Dsomedomain.lo= cal", > nonce=3D"WSSNE1kki+cE7oCG5vjVrxI/BZRRfmOmXKecloA=3D", uri=3D"/RPC", > cnonce=3D"Yjg5MWU3ZjdkYzYwNmNlMTc1ZmQyMmFmYmZkNGQyN2M=3D", nc=3D00000001, > qop=3Dauth, response=3D"c99a92d4c402ab592a908f92e82f08e1". > Accept: */*. > Host: 127.0.0.1:5060. > User-Agent: xmlrpcclient. > Content-Type: text/xml. > Content-Length: 167. > . > encoding=3D"UTF-8"?>dialplan.reload >=20 > T 127.0.0.1:5060 -> 127.0.0.1:57265 [AP] > HTTP/1.1 200 OK. > Sia: SIP/2.0/TCP 127.0.0.1:57265. > Content-Length: 108. >=20 > Cheers! >=20 > PS. Could not help at noticing Kamailio replying with =E2=80=9DSia=E2=80=9D= header in > 200OK message. I dont know if this is a bug or not but it looks a lot > like =E2=80=9DVia=E2=80=9D =E2=80=A6 :) >=20 > =E2=80=94Olli >=20 >> Daniel-Constantin Mierla kirjoitti 23.5.2017 kello=20 >> 21.23: >>=20 >> You can use the auth/auth_db modules do the the www-digest=20 >> authentication (which was actually defined first for http) like for=20 >> sip traffic -- you probably want to do the www not proxy auth, so use=20 >> the appropriate functions. >>=20 >> Cheers, >> Daniel >>=20 >> On Tue, May 23, 2017 at 3:09 PM, Oma > > wrote: >> Hello, >>=20 >> Username & password would be the desired way. >>=20 >> Cheers, >>=20 >> =E2=80=94Olli >>=20 >>> Daniel-Constantin Mierla >> > kirjoitti 23.5.2017 kello 15.32: >>>=20 >>> Hello, >>>=20 >>> do you want authentication with username and password or IP based=20 >>> authorization? >>>=20 >>> Cheers, >>> Daniel >>>=20 >>> On Tue, May 23, 2017 at 7:04 AM, Olli Attila >> > wrote: >>> Hello, >>>=20 >>> I got the POST request working now by adding the "listen=20 >>> tcp:127.0.0.1:5060 ". I tested this with=20 >>> dialplan.reload, dialplan.dump and htable.reload. Works ok. >>>=20 >>> Is there any way to authenticate the request in Kamailio? >>>=20 >>> Now all of the valid methods included in request:=20 >>> "http://127.0.0.1/RPC " are getting executed=20 >>> and Kamailio returns 200 OK directly. >>>=20 >>> Cheers, >>>=20 >>> --Olli >>>=20 >>>=20 >>>=20 >>>=20 >>> Diego Nadares kirjoitti 2017-05-22 15:06: >>> Hi Olli, >>>=20 >>> Did configure kamailio to listen on tcp:127.0.0.1? >>>=20 >>> Diego >>>=20 >>> El 22 may. 2017, a las 02:54, Olli Attila >> > escribi=C3=B3: >>>=20 >>> Hi, >>>=20 >>> I'm using kamailio 5.0.0 and trying to use core commands through=20 >>> xmlrpc interface but the requests are failing towards Kamailio. >>> I have compiled and enabled the xmlrpc module in config and I have=20 >>> this on my kamailio.cfg: >>>=20 >>>=20 >>> # XMLRPC routing >>> #!ifdef WITH_XMLRPC >>> route[XMLRPC] { >>> # allow XMLRPC from localhost >>> if ((method=3D=3D"POST" || method=3D=3D"GET") >>> && (src_ip=3D=3D127.0.0.1)) { >>> # close connection only for xmlrpclib user agents (there is a bug=20 >>> in >>> # xmlrpclib: it waits for EOF before interpreting the response). >>> if ($hdr(User-Agent) =3D~ "xmlrpclib") >>> set_reply_close(); >>> set_reply_no_connect(); >>> dispatch_rpc(); >>> exit; >>> } >>> send_reply("403", "Forbidden"); >>> exit; >>> } >>> #!endif >>>=20 >>> I have tried to test this by using curl and calling "core.uptime"=20 >>> method in xml body (core.uptime works when executed through kamcmd=20 >>> commandline tool). >>> The curl is called from the same machine that I have Kamailio=20 >>> installed on: >>>=20 >>> "curl -X POST -H 'Host: 127.0.0.1:5060 ' -H=20 >>> 'User-Agent: xmlrpcclient' -H 'Content-Type: text/xml' -d '>> version=3D'1.0'?>core.uptime= '=20 >>> http://127.0.0.1:5060 " >>>=20 >>> This fails and I only get: "curl: (7) Failed to connect to 127.0.0.1=20 >>> port 5060: Connection refused" >>>=20 >>> network traffic shows me this.. firewall is disabled completely when=20 >>> doing the test: >>> 1 0.000000 127.0.0.1 -> 127.0.0.1 TCP 74 55630=E2=86=925060 [SYN]= =20 >>> Seq=3D0 Win=3D43690 Len=3D0 MSS=3D65495 SACK_PERM=3D1 TSval=3D1347930477 = TSecr=3D0=20 >>> WS=3D64 >>> 2 0.000032 127.0.0.1 -> 127.0.0.1 TCP 54 5060=E2=86=9255630 [RST,= =20 >>> ACK] Seq=3D1 Ack=3D1 Win=3D0 Len=3D0 >>>=20 >>> Can anyone help me to get to the right direction with this? >>>=20 >>> Cheers, >>>=20 >>> --Olli >>>=20 >>>=20 >>> _______________________________________________ >>> Kamailio (SER) - Users Mailing List >>> sr-users(a)lists.kamailio.org >>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users=20 >>> >>>=20 >>> _______________________________________________ >>> Kamailio (SER) - Users Mailing List >>> sr-users(a)lists.kamailio.org >>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users=20 >>> >>>=20 >>> _______________________________________________ >>> Kamailio (SER) - Users Mailing List >>> sr-users(a)lists.kamailio.org >>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users=20 >>> >>>=20 >>>=20 >>>=20 >>> -- >>> Daniel-Constantin Mierla - http://www.asipto.com=20 >>> >>> http://twitter.com/#!/miconda -=20 >>> http://www.linkedin.com/in/miconda=20 >>> _____________________________________= __________ >>> Kamailio (SER) - Users Mailing List >>> sr-users(a)lists.kamailio.org >>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users=20 >>> >>=20 >>=20 >> _______________________________________________ >> Kamailio (SER) - Users Mailing List >> sr-users(a)lists.kamailio.org >> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users=20 >> >>=20 >>=20 >>=20 >>=20 >> -- >> Daniel-Constantin Mierla - http://www.asipto.com=20 >> >> http://twitter.com/#!/miconda -=20 >> http://www.linkedin.com/in/miconda=20 >> ______________________________________= _________ >> Kamailio (SER) - Users Mailing List >> sr-users(a)lists.kamailio.org >> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users >=20 >=20 > _______________________________________________ > Kamailio (SER) - Users Mailing List > sr-users(a)lists.kamailio.org > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users --===============0616206938==--