char uridigest[2 * SU_MD5_DIGEST_SIZE + 1];
char bigdigest[2 * SU_MD5_DIGEST_SIZE + 1];
char *nonce, *uri, *qop, *cnonce, *nc, *response, *input = NULL, *input2 = NULL;
- auth_res_t ret = AUTH_OK;
+ auth_res_t ret = AUTH_FORBIDDEN;
char *npassword = NULL;
int cnt = 0;
nonce = uri = qop = cnonce = nc = response = NULL;
su_md5_strupdate(&ctx, input2);
su_md5_hexdigest(&ctx, bigdigest);
su_md5_deinit(&ctx);
-
+
if (!strcasecmp(bigdigest, response)) {
ret = AUTH_OK;
} else {
}
sql = switch_mprintf("select passwd from sip_authentication where nonce='%q'", nonce);
-
if (switch_core_db_prepare(db, sql, -1, &stmt, 0)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Statement Error!\n");
goto fail;
}
if (authorization) {
- auth_res = parse_auth(profile, authorization, (char *)sip->sip_request->rq_method_name, key, keylen);
+ if ((auth_res = parse_auth(profile, authorization, (char *)sip->sip_request->rq_method_name, key, keylen)) == AUTH_STALE) {
+ stale = 1;
+ }
- if (auth_res != AUTH_OK && auth_res != AUTH_STALE) {
+ if (auth_res != AUTH_OK && !stale) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "send %s for [%s@%s]\n",
forbidden ? "forbidden" : "challange",
from_user, from_host);
switch_uuid_format(uuid_str, &uuid);
sql = switch_mprintf("delete from sip_authentication where user='%q' and host='%q';\n"
- "insert into sip_authentication values('%q','%q','%q','%q', %ld)",
- from_user,
- from_host,
- from_user,
- from_host,
- hexdigest,
- uuid_str,
- time(NULL) + 60);
-
+ "insert into sip_authentication values('%q','%q','%q','%q', %ld)",
+ from_user,
+ from_host,
+ from_user,
+ from_host,
+ hexdigest,
+ uuid_str,
+ time(NULL) + 60);
auth_str = switch_mprintf("Digest realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", from_host, uuid_str,
stale ? " stale=\"true\"," : "");
sip_t const *sip,
tagi_t tags[])
{
- handle_register(nua, profile, nh, sip, REG_REGISTER, NULL, 0);
+ char key[128] = "";
+ handle_register(nua, profile, nh, sip, REG_REGISTER, key, sizeof(key));
}