[ 'host' => 'localhost', 'port' => 8000, 'debug' => true, 'actorPath' => '/accounts/', ], 'logger' => [ 'driver' => '\Psr\Log\NullLogger' ], 'http' => [ 'timeout' => 15 ], 'cache' => [ 'enabled' => false, ] ]); // Create a response to a message for example $object = json_decode(" {\n "id": "http://localhost:8001/accounts/bob/status/123",\n "type": "Note",\n "published": "".date('Y-m-d\TH:i:s\Z')."",\n "attributedTo": "http://localhost:8001/accounts/bob",\n "inReplyTo": "http://localhost:8000/accounts/bob",\n "content": "

Hello world

",\n "to": "https://www.w3.org/ns/activitystreams#Public"\n }", true); $payload = json_encode( Type::create([ 'type' => 'Create', 'object' => $object ])->toArray() ); /* ------------------------------------------------------------------ | Prepare signature | ------------------------------------------------------------------ */ $date = gmdate('D, d M Y H:i:s T', time()); $host = 'localhost'; $path = '/my-path?q=ok'; $rsa = RSA::createKey() ->loadPrivateKey( file_get_contents( dirname(__DIR__, 2) . '/WebServer/distant/keys/private.pem' ) )->withHash("sha256"); // private key $plaintext = "(request-target) post $path\nhost: $host\ndate: $date"; $signature = $rsa->sign($plaintext); /* ------------------------------------------------------------------ | Prepare request | ------------------------------------------------------------------ */ $request = Request::create( 'http://localhost:8000' . $path, 'POST', [], // parameters [], // cookies [], // files $_SERVER, $payload ); $request->headers->set('accept', 'application/activity+json'); // Signature: keyId="",headers="(request-target) host date",signature="" $request->headers->set('Signature', 'keyId="http://localhost:8001/accounts/bob#main-key",headers="(request-target) host date",signature="' . base64_encode($signature) . '"'); $request->headers->set('host', $host); $request->headers->set('date', $date); $response = $server->inbox('bob@localhost:8000')->post($request); // Assert response type $this->assertInstanceOf(Response::class, $response); // Assert HTTP status code $this->assertEquals( 201, $response->getStatusCode() ); } } __halt_compiler();----SIGNATURE:----m5ibPuNeL7eF8ZG4VAP4wTZBdb9Rg8cX7DLyu44oM2EeehwFzo6oSw31XxO6rxR75rSk1KOVnc7yP9TaECLXLqBkUJ2VUVveaS5KSL/UfBcbaJ+8LxBCIcOQ01k0CZWJTsqgj/ySFNImcwclefTXgHY5J/IzEQqIBcYESq5x+UHUqrop3x/c5ClJIOOQInvTgioiLZ9nqJPI37G8QJgSl0oA7me24mGRMV/3V2Z8Hel5WR5M4SI8K9LF0TU+ZIiSC1HyiZUlioHwNryPGJYLE7ZLBt3Qhl6qdk7HRbacI9qP9GgccYjuK9TNZ88A0I4xs24K5jeTuzIRg/84aFFB8jamj87UzogWzUQ8L3b3qUtNPjGBhrjOAmMQkXGCrVbigKoW5TQiTZBhmRRTeWdfK7ZtS5N3tSnmMGFku1B/yYzPkguuvr9ghk1BecjdJX/kyAefMt83yAFdsZcqMdOJGQZ/jt9LY0h9iYdLUdkP71I+kG3h6Uz3iC6OeAAAHuhOI9gH29R6eH8/Xws7sF+TqjqGZk+i4HiAW6p9BNP8MfwAsBXUXE/JRKilLxbz6O0V3tqeN/ivbxQwai8ONAXrnPR4fLh/I6/zPFA8m2NZWuybKcMW7nmv224MixGaM+5jmTRCC0UmiBZi6iVKqgCtIq+MkhFhmUF874kU75u/ACQ=----ATTACHMENT:----MTMwNDA3MDk1MTQ4MDE0OSAxOTY4MjEyMjM0NDgyNzkgOTM1MTQzOTg0NjY0MzA3NQ==