diff --git a/lib/activitypub/federate.ts b/lib/activitypub/federate.ts index de6f991..3746f4b 100644 --- a/lib/activitypub/federate.ts +++ b/lib/activitypub/federate.ts @@ -67,7 +67,9 @@ async function cacheActor(actorObject: ActorObject) { actor.displayName = actorObject.name; actor.inbox = actorObject.inbox; actor.iconURL = iconURL; - actor.publicKeyPem = actorObject.publicKey.publicKeyPem; + if (actorObject.publicKey && actorObject.publicKey.publicKeyPem) { + actor.publicKeyPem = actorObject.publicKey.publicKeyPem; + } actor.isFollower = false; await getConnection().manager.save(actor); } diff --git a/lib/activitypub/middleware/http-signature.ts b/lib/activitypub/middleware/http-signature.ts index 4f583b8..f614ec4 100644 --- a/lib/activitypub/middleware/http-signature.ts +++ b/lib/activitypub/middleware/http-signature.ts @@ -25,7 +25,7 @@ export = async (req: Request, res: Response, next: NextFunction) => { console.log(`Could not retrieve actor ${req.body.actor} to validate HTTP signature for`, req.body); res.status(401).end("Could not retrieve actor to validate HTTP signature"); } - } else if (!validate(req, actor.publicKey.publicKeyPem)) { + } else if (!actor.publicKey || !actor.publicKey.publicKeyPem || !validate(req, actor.publicKey.publicKeyPem)) { console.log(`Could not validate HTTP signature for ${req.body.actor}`); res.status(401).end("Could not validate HTTP signature"); } else {