fix: closes #13405, catch errors in ap.verify

This commit is contained in:
Barış Soner Uşaklı
2025-05-11 22:31:00 -04:00
parent 20ab90694c
commit 8174578c5b

View File

@@ -232,6 +232,8 @@ ActivityPub.verify = async (req) => {
return false; return false;
} }
// Verify the signature string via public key
try {
// Break the signature apart // Break the signature apart
let { keyId, headers, signature, algorithm, created, expires } = req.headers.signature.split(',').reduce((memo, cur) => { let { keyId, headers, signature, algorithm, created, expires } = req.headers.signature.split(',').reduce((memo, cur) => {
const split = cur.split('="'); const split = cur.split('="');
@@ -273,8 +275,6 @@ ActivityPub.verify = async (req) => {
return memo; return memo;
}, []).join('\n'); }, []).join('\n');
// Verify the signature string via public key
try {
// Retrieve public key from remote instance // Retrieve public key from remote instance
ActivityPub.helpers.log(`[activitypub/verify] Retrieving pubkey for ${keyId}`); ActivityPub.helpers.log(`[activitypub/verify] Retrieving pubkey for ${keyId}`);
const { publicKeyPem } = await ActivityPub.fetchPublicKey(keyId); const { publicKeyPem } = await ActivityPub.fetchPublicKey(keyId);