mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
res_pjsip_stir_shaken: Fix JSON field ordering and disallowed TN characters.
The current STIR/SHAKEN signing process is inconsistent with the RFCs in a couple ways that can cause interoperability issues. RFC8225 specifies that the keys must be ordered lexicographically, but currently the fields are simply ordered according to the order in which they were added to the JSON object, which is not compliant with the RFC and can cause issues with some carriers. To fix this, we now leverage libjansson's ability to dump a JSON object sorted by key value, yielding the correct field ordering. Additionally, telephone numbers must have any leading + prefix removed and must not contain characters outside of 0-9, *, and # in order to comply with the RFCs. Numbers are now properly formatted as such. ASTERISK-30407 #close Change-Id: Iab76d39447c4b8cf133de85657dba02fda07f9a2
This commit is contained in:
committed by
Friendly Automation
parent
ecf49ff746
commit
0119f3ad48
@@ -1228,7 +1228,8 @@ struct ast_stir_shaken_payload *ast_stir_shaken_sign(struct ast_json *json)
|
||||
tmp_json = ast_json_object_get(json, "header");
|
||||
header = ast_json_dump_string(tmp_json);
|
||||
tmp_json = ast_json_object_get(json, "payload");
|
||||
payload = ast_json_dump_string(tmp_json);
|
||||
|
||||
payload = ast_json_dump_string_sorted(tmp_json);
|
||||
msg_len = strlen(header) + strlen(payload) + 2;
|
||||
msg = ast_calloc(1, msg_len);
|
||||
if (!msg) {
|
||||
@@ -1661,7 +1662,7 @@ AST_TEST_DEFINE(test_stir_shaken_verify)
|
||||
tmp_json = ast_json_object_get(json, "header");
|
||||
header = ast_json_dump_string(tmp_json);
|
||||
tmp_json = ast_json_object_get(json, "payload");
|
||||
payload = ast_json_dump_string(tmp_json);
|
||||
payload = ast_json_dump_string_sorted(tmp_json);
|
||||
|
||||
/* Test empty header parameter */
|
||||
returned_payload = ast_stir_shaken_verify("", payload, (const char *)signed_payload->signature,
|
||||
|
Reference in New Issue
Block a user