diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 4578e104740b77b9a048f30cbb657ef71a444fe4..650c68884c5ba4231bed81ac5bc04ed8e3944753 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -1850,7 +1850,7 @@ static void send_request_cb(void *token, pjsip_event *e) } AST_RWLIST_UNLOCK(&supplements); - if (tsx->status_code == 401 || tsx->status_code == 407) { + if ((tsx->status_code == 401 || tsx->status_code == 407) && req_data->endpoint) { if (!ast_sip_create_request_with_auth(&req_data->endpoint->outbound_auths, challenge, tsx, &tdata)) { pjsip_endpt_send_request(ast_sip_get_pjsip_endpoint(), tdata, -1, req_data->token, req_data->callback); } diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c index 2fe104aa84b3c66cec9a1154f3099e1fe27a3321..c72e58972926ead0b1d6fee75470be11966563ef 100644 --- a/res/res_pjsip/pjsip_options.c +++ b/res/res_pjsip/pjsip_options.c @@ -226,7 +226,7 @@ static int qualify_contact(struct ast_sip_endpoint *endpoint, struct ast_sip_con RAII_VAR(struct ast_sip_endpoint *, endpoint_local, ao2_bump(endpoint), ao2_cleanup); - if (!endpoint_local) { + if (!endpoint_local && contact->authenticate_qualify) { struct ao2_iterator *endpoint_iterator = find_endpoints(contact); /* try to find endpoints that are associated with the contact */ @@ -256,7 +256,7 @@ static int qualify_contact(struct ast_sip_endpoint *endpoint, struct ast_sip_con init_start_time(contact); ao2_ref(contact, +1); - if (ast_sip_send_request(tdata, NULL, endpoint_local, contact, + if (ast_sip_send_request(tdata, NULL, contact->authenticate_qualify ? endpoint_local : NULL, contact, qualify_contact_cb) != PJ_SUCCESS) { /* The callback will be called so we don't need to drop the contact ref*/ ast_log(LOG_ERROR, "Unable to send request to qualify contact %s\n",