@@ -259,7 +259,7 @@ public static function verify_http_signature( $request ) {
259259 }
260260
261261 if ( ! isset ( $ headers ['signature ' ] ) ) {
262- return new WP_Error ( 'activitypub_signature ' , __ ( 'Request not signed ' , 'activitypub ' ), array ( 'status ' => 403 ) );
262+ return new WP_Error ( 'activitypub_signature ' , __ ( 'Request not signed ' , 'activitypub ' ), array ( 'status ' => 401 ) );
263263 }
264264
265265 if ( array_key_exists ( 'signature ' , $ headers ) ) {
@@ -269,7 +269,7 @@ public static function verify_http_signature( $request ) {
269269 }
270270
271271 if ( ! isset ( $ signature_block ) || ! $ signature_block ) {
272- return new WP_Error ( 'activitypub_signature ' , __ ( 'Incompatible request signature. keyId and signature are required ' , 'activitypub ' ), array ( 'status ' => 403 ) );
272+ return new WP_Error ( 'activitypub_signature ' , __ ( 'Incompatible request signature. keyId and signature are required ' , 'activitypub ' ), array ( 'status ' => 401 ) );
273273 }
274274
275275 $ signed_headers = $ signature_block ['headers ' ];
@@ -279,12 +279,12 @@ public static function verify_http_signature( $request ) {
279279
280280 $ signed_data = self ::get_signed_data ( $ signed_headers , $ signature_block , $ headers );
281281 if ( ! $ signed_data ) {
282- return new WP_Error ( 'activitypub_signature ' , __ ( 'Signed request date outside acceptable time window ' , 'activitypub ' ), array ( 'status ' => 403 ) );
282+ return new WP_Error ( 'activitypub_signature ' , __ ( 'Signed request date outside acceptable time window ' , 'activitypub ' ), array ( 'status ' => 401 ) );
283283 }
284284
285285 $ algorithm = self ::get_signature_algorithm ( $ signature_block );
286286 if ( ! $ algorithm ) {
287- return new WP_Error ( 'activitypub_signature ' , __ ( 'Unsupported signature algorithm (only rsa-sha256 and hs2019 are supported) ' , 'activitypub ' ), array ( 'status ' => 403 ) );
287+ return new WP_Error ( 'activitypub_signature ' , __ ( 'Unsupported signature algorithm (only rsa-sha256 and hs2019 are supported) ' , 'activitypub ' ), array ( 'status ' => 401 ) );
288288 }
289289
290290 if ( \in_array ( 'digest ' , $ signed_headers , true ) && isset ( $ body ) ) {
@@ -300,7 +300,7 @@ public static function verify_http_signature( $request ) {
300300 }
301301
302302 if ( \base64_encode ( \hash ( $ hashalg , $ body , true ) ) !== $ digest [1 ] ) { // phpcs:ignore
303- return new WP_Error ( 'activitypub_signature ' , __ ( 'Invalid Digest header ' , 'activitypub ' ), array ( 'status ' => 403 ) );
303+ return new WP_Error ( 'activitypub_signature ' , __ ( 'Invalid Digest header ' , 'activitypub ' ), array ( 'status ' => 401 ) );
304304 }
305305 }
306306
@@ -313,7 +313,7 @@ public static function verify_http_signature( $request ) {
313313 $ verified = \openssl_verify ( $ signed_data , $ signature_block ['signature ' ], $ public_key , $ algorithm ) > 0 ;
314314
315315 if ( ! $ verified ) {
316- return new WP_Error ( 'activitypub_signature ' , __ ( 'Invalid signature ' , 'activitypub ' ), array ( 'status ' => 403 ) );
316+ return new WP_Error ( 'activitypub_signature ' , __ ( 'Invalid signature ' , 'activitypub ' ), array ( 'status ' => 401 ) );
317317 }
318318 return $ verified ;
319319 }
@@ -333,7 +333,7 @@ public static function get_remote_key( $key_id ) { // phpcs:ignore
333333 if ( isset ( $ actor ['publicKey ' ]['publicKeyPem ' ] ) ) {
334334 return \rtrim ( $ actor ['publicKey ' ]['publicKeyPem ' ] ); // phpcs:ignore
335335 }
336- return new WP_Error ( 'activitypub_no_remote_key_found ' , __ ( 'No Public-Key found ' , 'activitypub ' ), array ( 'status ' => 403 ) );
336+ return new WP_Error ( 'activitypub_no_remote_key_found ' , __ ( 'No Public-Key found ' , 'activitypub ' ), array ( 'status ' => 401 ) );
337337 }
338338
339339 /**
0 commit comments