diff --git a/includes/class-signature.php b/includes/class-signature.php index 96845d4..17a9a6f 100644 --- a/includes/class-signature.php +++ b/includes/class-signature.php @@ -225,7 +225,7 @@ class Signature { public static function get_key( $keyId ) { // phpcs:ignore // If there was no key passed to verify, it will find the keyId and call this // function to fetch the public key from stored data or a network fetch. - $actor = \strip_fragment_from_url( $keyId ); // phpcs:ignore + $actor = \Activitypub\get_actor_from_key( $keyId ); // phpcs:ignore $publicKeyPem = \Activitypub\get_publickey_by_actor( $actor, $keyId ); // phpcs:ignore return \rtrim( $publicKeyPem ); // phpcs:ignore } diff --git a/includes/functions.php b/includes/functions.php index 8f2e5d9..f731190 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -219,6 +219,15 @@ function get_publickey_by_actor( $actor, $key_id ) { return new \WP_Error( 'activitypub_no_public_key', \__( 'No "Public-Key" found', 'activitypub' ), $metadata ); } +function get_actor_from_key( $key_id ) { + $actor = \strip_fragment_from_url( $key_id ); + if ( $actor === $key_id ) { + // strip /main-key/ for GoToSocial. + $actor = \dirname( $key_id, 1 ); + } + return $actor; +} + function get_follower_inboxes( $user_id ) { $followers = \Activitypub\Peer\Followers::get_followers( $user_id ); $inboxes = array();