From b82df8a7da1bf035f4c9712ceda9366fd98cfb53 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 28 Feb 2014 23:23:30 +0500 Subject: [PATCH] FS-6287 this should either prevent the problem or spell out what is causing it. please test --- src/mod/endpoints/mod_sofia/sofia_reg.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 8baa418fe5..df2037f8d5 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -2323,7 +2323,14 @@ void sofia_reg_handle_sip_r_challenge(int status, switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Missing Authenticate Header!\n"); goto end; } + + scheme = (char const *) authenticate->au_scheme; + + if (zstr(scheme)) { + scheme = "Digest"; + } + if (authenticate->au_params) { for (indexnum = 0; (cur = (char *) authenticate->au_params[indexnum]); indexnum++) { if ((realm = strstr(cur, "realm="))) { @@ -2331,6 +2338,18 @@ void sofia_reg_handle_sip_r_challenge(int status, break; } } + + if (zstr(realm)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Realm: [%s] is invalid\n", switch_str_nil(realm)); + + for (indexnum = 0; (cur = (char *) authenticate->au_params[indexnum]); indexnum++) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "DUMP: [%s]\n", cur); + } + goto end; + } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "NO AUTHENTICATE PARAMS\n"); + goto end; } if (!gateway) { @@ -2399,11 +2418,6 @@ void sofia_reg_handle_sip_r_challenge(int status, switch_event_destroy(&locate_params); } - if (!(scheme && realm)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No scheme and realm!\n"); - goto end; - } - if (sip_auth_username && sip_auth_password) { switch_snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, sip_auth_username, sip_auth_password); } else if (gateway) {