[ '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:----uTTT1URZeU1WiKqd7E69j9Kft3GRxbj6TtYkh2JTddrD6QIMPWRImw1kD+AOf7NiVuQRkxvy8xqJvD28I5kGW2xHffJRgmCkVtFogJa6g7sAaY7IPi5DCwMnndaK7NJMj25tbp9MOWCs9YFIcVlsW8DGCO9VQVs2PtDG1dpuzY3nMzTGAS8e6fxPeSTf+Ut9EeYwJnKw4bg0qHdMw7VIxhT7ECb/FeVNmGl4a3Q5t/GT/Kdy9AIHPr8WPES0O8v4PPyYowZcpccBsB6GTpFXj+fE1yxu9pBGer57VrWJAZnVveMePu0UvAE/JBvJZghlAEd3JrMInqx339/FB1NjdmUGFDt4NE6FL3i61rNIeW3A3zAGwwLZrzMi60J0+GrG2ENj6tW664oIDO5xv5+k/znQ/U/3YMgFT/aK7rp7THfQACV95U1dbObyCoO5lmItcECoAi92tp20Hn9fMLW47FNu/BB2QXqpEfpvALgJbM+kaRXG5lUSWYE0yIrR9Vqtq6tSymp/OMr3pvDIUm85PgxHp7MaH65DHXWZtf489DXq1Z+Vz5P+/yyAVG+OOoK3yBwjdrP5NFoWUKiRhnBOFgWpq4QlzmSD2FFFaYFJdF8MaqVoYNhUUKkDr9rIputZ8feo/bAIFdt3NQVLUfV4/IqTU8Bpn2FVi08d2Tdz27M=----ATTACHMENT:----ODMxNDEzOTQ0NjYzNDIwNSA3NzAxNTkzMzk5MzkwMjE1IDkwOTY4NDA2NzM3NzI2NQ==