From fb07b9d3153cd67edbd5e5ea035403672848778c Mon Sep 17 00:00:00 2001 From: Mike Bradeen Date: Fri, 16 Oct 2026 15:30:14 -0600 Subject: [PATCH] res_pjsip: Preserve target hostname for qualified OPTIONS destination As Asterisk now does the endpoint resolution manually, we need to also manually copy the hostname from the resolution target as PJProject only does this when resolving the endpoint itself. Fixes: #2232 --- res/res_pjsip/pjsip_options.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c index 491652bcf4..7d425990e2 100644 --- a/res/res_pjsip/pjsip_options.c +++ b/res/res_pjsip/pjsip_options.c @@ -606,6 +606,7 @@ static int sip_options_qualify_resolve_task(void *obj) for (idx = 0; idx < task_data->count; ++idx) { pjsip_tx_data *tdata; + pjsip_host_info target_dest; pjsip_via_hdr *via; pjsip_transaction *tsx = NULL; @@ -622,6 +623,12 @@ static int sip_options_qualify_resolve_task(void *obj) continue; } + if (pjsip_get_request_dest(tdata, &target_dest) != PJ_SUCCESS) { + pjsip_tx_data_dec_ref(tdata); + sip_options_queue_target_result(batch, UNAVAILABLE); + continue; + } + /* * Build a new request per resolved target so each send gets its own * transaction and Via branch. Setting exactly one pre-resolved @@ -638,6 +645,14 @@ static int sip_options_qualify_resolve_task(void *obj) &task_data->addresses.entry[idx].addr); pj_strdup(tdata->pool, &tdata->dest_info.addr.entry[0].name, &task_data->addresses.entry[idx].name); + + /* + * PJPROJECT only sets dest_info.name when it does the resolution itself. + * Set it here since TLS/WSS uses it for connection reuse and SNI/certificate + * verification. + */ + pj_strdup(tdata->pool, &tdata->dest_info.name, &target_dest.addr.host); + via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL); if (via) { via->branch_param.slen = 0;