<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    have you mangled the sip message you pasted here? I see a white
    space in front of username in From/To headers, which can lead in
    mismatching the authentication username with caller id username.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <div class="moz-cite-prefix">On 07/03/16 21:08, Bruno Henrique Gomes
      Gouvêa wrote:<br>
    </div>
    <blockquote
cite="mid:CAFBSE6t=4BevZ9PfHjh2DgCQ4musfaL7JR1ndOjh0RSy2RSVSg@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hello,
        <div><br>
        </div>
        <div>
          <div>I did a tcpdump as directed, the softphone I use to test
            (Zoiper) tries to send a register without authorization
            header when receiving sip 401, it sends a new register with
            the authorization headers. This second attempt to register
             is in the log and still does not allow the correct
            authentication.</div>
          <div>I took a look at the packet that kamailio is receiving
            and still could not find the problem, someone has idea?</div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>        REGISTER sip: <a moz-do-not-send="true"
              href="http://pabx999999.ligou.me">pabx999999.ligou.me</a>;
            transport = UDP SIP / 2.0</div>
          <div>        Via: SIP / 2.0 / UDP
            189.13.125.28:49288;branch=z9hG4bK-d8754z-f96a8271ea34f240-1---d8754z-</div>
          <div>        Max-Forwards: 70</div>
          <div>        Contact: <sip: <a moz-do-not-send="true"
              href="mailto:101_pabx999999.ligou.me@189.13.125.28">101_pabx999999.ligou.me@189.13.125.28</a>:
            49288; rinstance = 98fe0089b166bd85; transport = UDP></div>
          <div>        To: <sip: <a moz-do-not-send="true"
              href="mailto:101_pabx999999.ligou.me@pabx999999.ligou.me">101_pabx999999.ligou.me@pabx999999.ligou.me</a>;
            transport = UDP></div>
          <div>        From: <sip: <a moz-do-not-send="true"
              href="mailto:101_pabx999999.ligou.me@pabx999999.ligou.me">101_pabx999999.ligou.me@pabx999999.ligou.me</a>;
            transport = UDP>; tag = 9d3ef068</div>
          <div>        Call-ID:
            YWQ5YzU4ZTc4MGU5NWE3OGI3Y2U2YjdmZDA0YTFmZmE.</div>
          <div>        CSeq: 3 REGISTER</div>
          <div>        Expires: 3600</div>
          <div>        Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER,
            MESSAGE, OPTIONS, INFO, SUBSCRIBE</div>
          <div>        Supported: replaces, norefersub, extended-refer,
            timer, X-cisco-serviceuri</div>
          <div>        User-Agent: Z 3.6.25251 r25476</div>
          <div>        Authorization: Digest username="<a
              moz-do-not-send="true"
              href="http://101_pabx999999.ligou.me">101_pabx999999.ligou.me</a>",realm="<a
              moz-do-not-send="true" href="http://pabx999999.ligou.me">pabx999999.ligou.me</a>",nonce="Vt3evVbd3ZGT5CKFEKVFXx3NZHKisGcp",uri="sip:<a
              moz-do-not-send="true" href="http://pabx999999.ligou.me">pabx999999.ligou.me</a>;transport=UDP",response="6b3a6709fa3ec3ad313811a704ffb6d9",algorithm=MD5</div>
          <div>        Allow-Events: presence, KPML</div>
          <div>        Content-Length: 0</div>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Thank you!</div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br clear="all">
        <div>
          <div class="gmail_signature">
            <div dir="ltr">
              <div>
                <div dir="ltr" style="font-size:12.8000001907349px">
                  <div>--------------------------------------------</div>
                  <div><br>
                  </div>
                  <div>Bruno H. G. Gouvêa</div>
                  <div><br>
                  </div>
                  <div>CEO - CiberCloud LTDA</div>
                  <div><a moz-do-not-send="true"
                      href="http://cibercloud.com.br/"
                      style="color:rgb(17,85,204)" target="_blank">http://cibercloud.com.br</a></div>
                  <div><a moz-do-not-send="true" href="http://ligou.me/"
                      style="color:rgb(17,85,204)" target="_blank">http://ligou.me</a><br>
                  </div>
                  <div><br>
                  </div>
                </div>
                <div style="font-size:12.8000001907349px"><br
                    clear="all">
                  <div>--- <br>
                     Bruno H. G. Gouvêa<br>
                    <br>
                    <br>
                     Tel.: <a moz-do-not-send="true"
                      href="tel:%2831%2999554646" value="+553199554646"
                      style="color:rgb(17,85,204)" target="_blank">(31)99554646</a><br>
                    ---</div>
                </div>
                <br>
              </div>
            </div>
          </div>
        </div>
        <br>
        <div class="gmail_quote">2016-03-07 16:42 GMT-03:00
          Daniel-Constantin Mierla <span dir="ltr"><<a
              moz-do-not-send="true" href="mailto:miconda@gmail.com"
              target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:miconda@gmail.com">miconda@gmail.com</a></a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> Hello,<br>
              <br>
              can you look at the SIP traffic and see if the realm
              parameter for authrozation is matching what you have in
              the config. The logs messages show:<br>
              <br>
              <pre style="outline:none;padding:0px;margin:0px;font-family:monospace,'Lucida Grande',Verdana,Arial,Helvetica,sans-serif;white-space:pre-wrap;color:rgb(51,51,51);font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;background-color:rgb(255,255,255)">Mar  7 10:59:13 p /usr/sbin/kamailio[29558]: ERROR: *** cfgtrace: c=[//etc/kamailio/kamailio.cfg] l=946 a=27 n=auth_check
Mar  7 10:59:13 p /usr/sbin/kamailio[29558]: DEBUG: auth_db [authorize.c:486]: auth_check(): realm [<a moz-do-not-send="true" href="http://pabx999999.ligou.me" target="_blank">pabx999999.ligou.me</a>] table [subscriber] flags [0]
Mar  7 10:59:13 p /usr/sbin/kamailio[29558]: DEBUG: auth [api.c:86]: pre_auth(): auth:pre_auth: Credentials with realm '<a moz-do-not-send="true" href="http://pabx999999.ligou.me" target="_blank">pabx999999.ligou.me</a>' not found
Mar  7 10:59:13 p /usr/sbin/kamailio[29558]: DEBUG: auth_db [authorize.c:252]: digest_authenticate_hdr(): no credentials
</pre>
              <br>
              Meaning that headers with expected realm were not found.<br>
              <br>
              You can eventually make available the output of ngrep for
              a registration exposing the issue.<br>
              <br>
              Cheers,<br>
              Daniel
              <div>
                <div class="h5"><br>
                  <br>
                  <div>On 07/03/16 17:10, Bruno Henrique Gomes Gouvêa
                    wrote:<br>
                  </div>
                </div>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5">
                    <div dir="ltr">Hello,
                      <div><br>
                      </div>
                      <div>Thanks for the reply.</div>
                      <div><br>
                      </div>
                      <div>Debug log: <a moz-do-not-send="true"
                          href="http://pasted.co/63d576ae"
                          target="_blank">http://pasted.co/63d576ae</a><br>
                      </div>
                    </div>
                    <div class="gmail_extra"><br clear="all">
                      <div>
                        <div>
                          <div dir="ltr">
                            <div>
                              <div dir="ltr"
                                style="font-size:12.8000001907349px">
                                <div>--------------------------------------------</div>
                                <div><br>
                                </div>
                                <div>Bruno H. G. Gouvêa</div>
                                <div><br>
                                </div>
                                <div>CEO - CiberCloud LTDA</div>
                                <div><a moz-do-not-send="true"
                                    href="http://cibercloud.com.br/"
                                    style="color:rgb(17,85,204)"
                                    target="_blank">http://cibercloud.com.br</a></div>
                                <div><a moz-do-not-send="true"
                                    href="http://ligou.me/"
                                    style="color:rgb(17,85,204)"
                                    target="_blank">http://ligou.me</a><br>
                                </div>
                                <div><br>
                                </div>
                              </div>
                              <div style="font-size:12.8000001907349px"><br
                                  clear="all">
                                <div>--- <br>
                                   Bruno H. G. Gouvêa<br>
                                  <br>
                                  <br>
                                   Tel.: <a moz-do-not-send="true"
                                    href="tel:%2831%2999554646"
                                    value="+553199554646"
                                    style="color:rgb(17,85,204)"
                                    target="_blank">(31)99554646</a><br>
                                  ---</div>
                              </div>
                              <br>
                            </div>
                          </div>
                        </div>
                      </div>
                      <br>
                      <div class="gmail_quote">2016-03-04 18:17
                        GMT-03:00 Bruno Henrique Gomes Gouvêa <span
                          dir="ltr"><<a moz-do-not-send="true"
                            href="mailto:brunohenriquebh@gmail.com"
                            target="_blank">brunohenriquebh@gmail.com</a>></span>:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div dir="ltr">
                            <div>Hello,</div>
                            <div><br>
                            </div>
                            <div>First excuse any mistakes in English.
                              I'm working on a platform that makes use
                              of integrated Kamailio with asterisk
                              (Elastix mt).</div>
                            <div><br>
                            </div>
                            <div>This platform allows the login of my
                              SIP clients via the extension number and
                              the client's domain, where the kamailio
                              after authentication change the username
                              to sip EXTENSION + _ + DOMAIN (expected by
                              Asterisk) and sends to the asterisk.</div>
                            <div><br>
                            </div>
                            <div>I need the client can also send the sip
                              user in standard EXTENSION + _ + DOMAIN,
                              for it changed the view subscriber to also
                              return a username record in the format
                              that the softphone is sending, but the
                              platform still seems not authenticate the
                              REGISTER using new way functions in
                              auth_check ("$ FD", "subscriber", "0") and
                              auth_challenge ("$ FD", "0").</div>
                            <div><br>
                            </div>
                            <div>Thus works:</div>
                            <div>Login: 101</div>
                            <div>Domain/server: <a
                                moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a></div>
                            <div>Password: PASSWORD_PLAIN</div>
                            <div><br>
                            </div>
                            <div><br>
                            </div>
                            <div><br>
                            </div>
                            <div>This way does not work:</div>
                            <div>Login: <a moz-do-not-send="true"
                                href="http://101_pabx999999.ligou.me"
                                target="_blank">101_pabx999999.ligou.me</a></div>
                            <div>Domain/server: <a
                                moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a></div>
                            <div>Password: PASSWORD_PLAIN</div>
                            <div><br>
                            </div>
                            <div><br>
                            </div>
                            <div>Already got a good look at the
                              documentation and could not find the
                              problem, could give me some help?</div>
                            <div><br>
                            </div>
                            <div><br>
                            </div>
                            <div>Kamailio.cfg: <a
                                moz-do-not-send="true"
                                href="http://pasted.co/db8fb3a2"
                                target="_blank"><a class="moz-txt-link-freetext" href="http://pasted.co/db8fb3a2">http://pasted.co/db8fb3a2</a></a></div>
                            <div>Execution debug log: <a
                                moz-do-not-send="true"
                                href="http://pasted.co/49bfe5bf"
                                target="_blank"><a class="moz-txt-link-freetext" href="http://pasted.co/49bfe5bf">http://pasted.co/49bfe5bf</a></a></div>
                            <div>Contents view subscriber:</div>
                            <div>+-----------------------------+---------------------+---------------+------+</div>
                            <div>| username                    | domain
                                           | ha1           | ha1b |</div>
                            <div>+-----------------------------+---------------------+---------------+------+</div>
                            <div>| admin                       | <a
                                moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div>| adminIM                     | <a
                                moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div>| 101                         | <a
                                moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div>| 103                         | <a
                                moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div>| 103IM                       | <a
                                moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div>| <a moz-do-not-send="true"
                                href="http://admin_pabx999999.ligou.me"
                                target="_blank">admin_pabx999999.ligou.me</a>
                                | <a moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div>| <a moz-do-not-send="true"
                                href="http://adminIM_pabx999999.ligou.me"
                                target="_blank">adminIM_pabx999999.ligou.me</a>
                              | <a moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div>| <a moz-do-not-send="true"
                                href="http://101_pabx999999.ligou.me"
                                target="_blank">101_pabx999999.ligou.me</a>
                                  | <a moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div>| <a moz-do-not-send="true"
                                href="http://103_pabx999999.ligou.me"
                                target="_blank">103_pabx999999.ligou.me</a>
                                  | <a moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div>| <a moz-do-not-send="true"
                                href="http://103IM_pabx999999.ligou.me"
                                target="_blank">103IM_pabx999999.ligou.me</a>
                                | <a moz-do-not-send="true"
                                href="http://pabx999999.ligou.me"
                                target="_blank">pabx999999.ligou.me</a>
                              | PASSWORD_PLAIN| NULL |</div>
                            <div><br>
                            </div>
                            <div>
                              <div>
                                <div dir="ltr">
                                  <div>
                                    <div dir="ltr"
                                      style="font-size:12.8px">
                                      <div>--------------------------------------------</div>
                                      <div><br>
                                      </div>
                                      <div>Bruno H. G. Gouvêa</div>
                                      <div><br>
                                      </div>
                                      <div><br>
                                      </div>
                                    </div>
                                    <div style="font-size:12.8px">
                                      <div>---</div>
                                    </div>
                                    <br>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                    <br>
                    <fieldset></fieldset>
                    <br>
                  </div>
                </div>
                <pre>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a moz-do-not-send="true" href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a moz-do-not-send="true" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><span class="HOEnZb"><font color="#888888">
</font></span></pre>
                <span class="HOEnZb"><font color="#888888"> </font></span></blockquote>
              <span class="HOEnZb"><font color="#888888"> <br>
                  <pre cols="72">-- 
Daniel-Constantin Mierla
<a moz-do-not-send="true" href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Kamailio Advanced Training, Berlin, March 7-9, 2016 - <a moz-do-not-send="true" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a></pre>
                </font></span></div>
            <br>
            _______________________________________________<br>
            SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
            mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users"
              rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio Advanced Training, Berlin, March 7-9, 2016 - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a></pre>
  </body>
</html>