commit be54d22
grunfink
·
2026-06-01 06:21:13 +0000 UTC
parent 7b40d93
Ensure publicKeyPem never contain trailing text after the end marker.
1 files changed,
+12,
-1
+12,
-1
1@@ -1829,7 +1829,18 @@ xs_dict *msg_actor(snac *snac)
2
3 keys = xs_dict_append(keys, "id", kid);
4 keys = xs_dict_append(keys, "owner", snac->actor);
5- keys = xs_dict_append(keys, "publicKeyPem", xs_dict_get(snac->key, "public"));
6+
7+ xs *public_key_pem = xs_dup(xs_dict_get(snac->key, "public"));
8+
9+ if (xs_is_string(public_key_pem)) {
10+ /* crop any garbage after the PEM */
11+ const char *pem_trailer = "END PUBLIC KEY-----\n";
12+ int i = xs_str_in(public_key_pem, pem_trailer);
13+ if (i > 0)
14+ public_key_pem[i + strlen(pem_trailer)] = '\0';
15+ }
16+
17+ keys = xs_dict_append(keys, "publicKeyPem", public_key_pem);
18 msg = xs_dict_set(msg, "publicKey", keys);
19
20 /* if the "bot" config field is set to true, change type to "Service" */