aboutsummaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/activitypub.c b/activitypub.c
index 49e81f4..29a4b66 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1829,7 +1829,18 @@ xs_dict *msg_actor(snac *snac)
keys = xs_dict_append(keys, "id", kid);
keys = xs_dict_append(keys, "owner", snac->actor);
- keys = xs_dict_append(keys, "publicKeyPem", xs_dict_get(snac->key, "public"));
+
+ xs *public_key_pem = xs_dup(xs_dict_get(snac->key, "public"));
+
+ if (xs_is_string(public_key_pem)) {
+ /* crop any garbage after the PEM */
+ const char *pem_trailer = "END PUBLIC KEY-----\n";
+ int i = xs_str_in(public_key_pem, pem_trailer);
+ if (i > 0)
+ public_key_pem[i + strlen(pem_trailer)] = '\0';
+ }
+
+ keys = xs_dict_append(keys, "publicKeyPem", public_key_pem);
msg = xs_dict_set(msg, "publicKey", keys);
/* if the "bot" config field is set to true, change type to "Service" */