diff options
author | Mark Michelson <mmichelson@digium.com> | 2014-12-18 14:43:53 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2014-12-18 14:43:53 +0000 |
commit | 5bd5f580c13e5d96375a3aeeba1c2a0d3eeac17c (patch) | |
tree | 89eb85dd18c26a2e768ea504e7b2078706ec6def /channels | |
parent | b4621cd0f538dc71a0418b57750a79e39ace2944 (diff) |
Ensure the correct value is returned for CHANNEL(pjsip, secure)
Prior to this patch, we were using the PJSIP dialog's secure flag
to determine if a secure transport was being used. Unfortunately,
the dialog's secure flag was only set if a SIPS URI were in use,
as required by RFC 3261 sections 12.1.1 and 12.1.2. What we're interested
in is not dialog security, but transport security. This code change
switches to a model where we use the dialog's target URI to determine
what transport would be used to communicate, and then check if that
transport is secure.
AST-1450 #close
Reported by John Bigelow
Review: https://reviewboard.asterisk.org/r/4277
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@429739 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/pjsip/dialplan_functions.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/channels/pjsip/dialplan_functions.c b/channels/pjsip/dialplan_functions.c index 6c0aff30b..2cc4f9c74 100644 --- a/channels/pjsip/dialplan_functions.c +++ b/channels/pjsip/dialplan_functions.c @@ -580,7 +580,11 @@ static int channel_read_pjsip(struct ast_channel *chan, const char *type, const dlg = channel->session->inv_session->dlg; if (!strcmp(type, "secure")) { - snprintf(buf, buflen, "%d", dlg->secure ? 1 : 0); + pjsip_host_info dest; + pj_pool_t *pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "secure-check", 128, 128); + pjsip_get_dest_info(dlg->target, NULL, pool, &dest); + snprintf(buf, buflen, "%d", dest.flag & PJSIP_TRANSPORT_SECURE ? 1 : 0); + pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool); } else if (!strcmp(type, "target_uri")) { pjsip_uri_print(PJSIP_URI_IN_REQ_URI, dlg->target, buf, buflen); buf_copy = ast_strdupa(buf); |