mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	fix: additional verbose logging for signature verification
This commit is contained in:
		| @@ -152,7 +152,9 @@ ActivityPub.sign = async ({ key, keyId }, url, payload) => { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| ActivityPub.verify = async (req) => { | ActivityPub.verify = async (req) => { | ||||||
|  | 	winston.verbose('[activitypub/verify] Starting signature verification...'); | ||||||
| 	if (!req.headers.hasOwnProperty('signature')) { | 	if (!req.headers.hasOwnProperty('signature')) { | ||||||
|  | 		winston.verbose('[activitypub/verify]   Failed, no signature header.'); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -179,14 +181,17 @@ ActivityPub.verify = async (req) => { | |||||||
| 	// Verify the signature string via public key | 	// Verify the signature string via public key | ||||||
| 	try { | 	try { | ||||||
| 		// Retrieve public key from remote instance | 		// Retrieve public key from remote instance | ||||||
|  | 		winston.verbose(`[activitypub/verify] Retrieving pubkey for ${keyId}`); | ||||||
| 		const { publicKeyPem } = await ActivityPub.fetchPublicKey(keyId); | 		const { publicKeyPem } = await ActivityPub.fetchPublicKey(keyId); | ||||||
|  |  | ||||||
| 		const verify = createVerify('sha256'); | 		const verify = createVerify('sha256'); | ||||||
| 		verify.update(signed_string); | 		verify.update(signed_string); | ||||||
| 		verify.end(); | 		verify.end(); | ||||||
|  | 		winston.verbose('[activitypub/verify] Attempting signed string verification'); | ||||||
| 		const verified = verify.verify(publicKeyPem, signature, 'base64'); | 		const verified = verify.verify(publicKeyPem, signature, 'base64'); | ||||||
| 		return verified; | 		return verified; | ||||||
| 	} catch (e) { | 	} catch (e) { | ||||||
|  | 		winston.verbose('[activitypub/verify]   Failed, key retrieval or verification failure.'); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user