Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 309764) +++ channels/chan_sip.c (working copy) @@ -18507,10 +18507,10 @@ const char *md5secret; struct sip_auth *auth = NULL; /* Realm authentication */ - if (!ast_strlen_zero(p->domain)) + if (!ast_strlen_zero(p->uri)) + ast_copy_string(uri, p->uri, sizeof(uri)); + else if (!ast_strlen_zero(p->domain)) ast_copy_string(uri, p->domain, sizeof(uri)); - else if (!ast_strlen_zero(p->uri)) - ast_copy_string(uri, p->uri, sizeof(uri)); else snprintf(uri, sizeof(uri), "sip:%s@%s", p->username, ast_sockaddr_stringify_host(&p->sa));