<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16175">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_stir_shaken: Use correct Caller ID to lookup certificate.<br><br>Determine the Caller ID to use for certificate lookup based on the<br>same logic we use when setting up the INVITE session. This allows<br>Caller ID set via the CALLERID() function to to be used for<br>STIR/SHAKEN certificate lookup.<br><br>ASTERISK-29169 #close<br><br>Change-Id: I6f1f9c56ceb989d3ad4e16f069b4273166614b9a<br>---<br>M res/res_pjsip_stir_shaken.c<br>1 file changed, 21 insertions(+), 7 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/75/16175/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_stir_shaken.c b/res/res_pjsip_stir_shaken.c</span><br><span>index de1513b..c722085 100644</span><br><span>--- a/res/res_pjsip_stir_shaken.c</span><br><span>+++ b/res/res_pjsip_stir_shaken.c</span><br><span>@@ -208,7 +208,7 @@</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static int add_identity_header(const struct ast_sip_session *session, pjsip_tx_data *tdata)</span><br><span style="color: hsl(120, 100%, 40%);">+static int add_identity_header(const struct ast_sip_session *session, const struct ast_party_id *party_id, pjsip_tx_data *tdata)</span><br><span> {</span><br><span> static const pj_str_t identity_str = { "Identity", 8 };</span><br><span> pjsip_generic_string_hdr *identity_hdr;</span><br><span>@@ -258,7 +258,7 @@</span><br><span> json = ast_json_pack("{s: {s: s, s: s, s: s}, s: {s: {s: s}, s: {s: s}}}",</span><br><span> "header", "alg", "ES256", "ppt", "shaken", "typ", "passport",</span><br><span> "payload", "dest", "tn", dest_tn, "orig", "tn",</span><br><span style="color: hsl(0, 100%, 40%);">- session->id.number.str);</span><br><span style="color: hsl(120, 100%, 40%);">+ party_id->number.str);</span><br><span> if (!json) {</span><br><span> ast_log(LOG_ERROR, "Failed to allocate memory for STIR/SHAKEN JSON\n");</span><br><span> return -1;</span><br><span>@@ -333,20 +333,34 @@</span><br><span> </span><br><span> static void stir_shaken_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_party_id effective_id;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_party_id connected_id;</span><br><span style="color: hsl(120, 100%, 40%);">+ int res;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (!session->endpoint->stir_shaken) {</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_strlen_zero(session->id.number.str) && session->id.number.valid) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_party_id_init(&connected_id);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_lock(session->channel);</span><br><span style="color: hsl(120, 100%, 40%);">+ effective_id = ast_channel_connected_effective_id(session->channel);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_party_id_copy(&connected_id, &effective_id);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_unlock(session->channel);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_strlen_zero(connected_id.number.str) || !connected_id.number.valid) {</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* If adding the Identity header fails for some reason, there's no point</span><br><span style="color: hsl(0, 100%, 40%);">- * adding the Date header.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- if ((add_identity_header(session, tdata)) != 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ res = add_identity_header(session, &connected_id, tdata);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_party_id_free(&connected_id);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If adding the Identity header failed for some reason, there's no point</span><br><span style="color: hsl(120, 100%, 40%);">+ * adding the Date header. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res) {</span><br><span> return;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> add_date_header(session, tdata);</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16175">change 16175</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/16175"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I6f1f9c56ceb989d3ad4e16f069b4273166614b9a </div>
<div style="display:none"> Gerrit-Change-Number: 16175 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>