mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +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
15
main/json.c
15
main/json.c
@@ -456,8 +456,19 @@ int ast_json_object_iter_set(struct ast_json *object, struct ast_json_iter *iter
|
||||
*/
|
||||
static size_t dump_flags(enum ast_json_encoding_format format)
|
||||
{
|
||||
return format == AST_JSON_PRETTY ?
|
||||
JSON_INDENT(2) | JSON_PRESERVE_ORDER : JSON_COMPACT;
|
||||
size_t jansson_dump_flags;
|
||||
|
||||
if (format & AST_JSON_PRETTY) {
|
||||
jansson_dump_flags = JSON_INDENT(2);
|
||||
} else {
|
||||
jansson_dump_flags = JSON_COMPACT;
|
||||
}
|
||||
|
||||
if (format & AST_JSON_SORTED) {
|
||||
jansson_dump_flags |= JSON_SORT_KEYS;
|
||||
}
|
||||
|
||||
return jansson_dump_flags;
|
||||
}
|
||||
|
||||
char *ast_json_dump_string_format(struct ast_json *root, enum ast_json_encoding_format format)
|
||||
|
Reference in New Issue
Block a user