[ '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:----kEMod6KqFY703urip4rjaDwBV3rW3FWne7clerZO4B/E8Uq9tlRtCl8hVrXuG5dckxq+Vo0/avduey+P47wMRmp78H9uHjB2rm9mvhKROaApHlnDmrpIPz6/mjjIOEopx4hDXftN4DF8wU7y0Zq7A8C5DLahS1EgIx0F8hBMa3D8X7GlMVObLwLS7deuMtHdTBbIehqm0UcTlAqCPADPHaDuGq30kCHv315znXwUQYuOSgSON+8f/Tdy4xgJXhENXhZf1sgjWgKlnqO5Dla/ghs6WaHdzTwkPmWffmyz152GV4olvzTuifWBg66I16dAID+NHEXbKVtovMX7ROvaIVQkypEKQzM3tnKTH1PgwAyh1z+UC/peSdGaPD2UeQGa+XjK/kqk5ehWkA8HetuFBJ4iTG08UM0e5Xwkq/FZWoLoRIQ8QJlI/2Fk+6JCST4JAqjrURXJm77x8KjxYgVuk2qUau/H1z/23HjixGUFYZ9gZ8f8qqBQgYdE3iblNzTcrcqAfKE8WFFW7FOyRwJGneoRcbXaNxwcyxYV3rdzhNhJQ5n2lPY/o3a8aJPaefto6HBZ4oDCkgmFjAS/1wY0umEZFgYBuLww9skVcGJy5c1c3EQGtZk1B236JcY/6r9+ffnkBm+uCvdjRHR9u/NPkALy/Zj1L15mR8lCXfkeRjg=----ATTACHMENT:----NDU2NTY0NTUzNTMwNjY3MCA0Njk0OTMwODY5OTQzMzc0IDQ3NDQ5MTAyOTg0NDI4MDY=