[ '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:----vRIPjMiKrM7sAtWoD9sV8Z7VzM40Hawlx9wdPvHMqzm9ZobKm1tg8+c41eTJTx7OxYuS1xFsinN7TSZVd9Xsgt6fDCnse/UTSQo+t64x7ADpSNDNI+ndxoDUdqPpc1Li0IZ5tRjSpKXeqgK/onbIP+KYLGiCpAyz7KCGpJhh4rNMup/tB7La2cY5Ge62mhC/cQ0ber3zFcEPuGKeuWrmC1GM9wUM/NO0/AY9RiOL6Gb24ZvqyUmjIPP8u0MaoBiGdCyicjoAyL5rj+FyAzxLO+ncZPElhet5BEqkPM/y8dRSBboqhnpcI0EBOmREYGJUHg4o41oicq9kQZtj6LXUkb/RnaiXxZMtD7VS4Q+Yt+8Lw5ZwVjgf9lphmsnEcqxptR9q2+4pa/mw8ktlVBfF8hlByTcEyUeEOwEEIIqVTHdtWNXCT/ttTlH2Bf0/9xAFi0HP06tnXGl/Bv9PHTdu3RBVwPg1GxtI4oUioc2KK7bv2YlnOuRtJXfSC1HRvQ7c9CHrhlIwj3c+5nk4aEcwKNrjfRxDH9HpNZCwSIPeQVUZKdu1dzNEa8oLFt+VmKDdpA1rsxl3ttQY9yC8qH3zD6Ag3PI51jTlB0uF7CLy+4tgfWlAtB/fPn9e5UXzf1tPcURU3T4ZcRabYllMWvaR3IW7WEGkkeQGYD/7+R3gpzk=----ATTACHMENT:----MzU2ODYzMTcyNDc3NzQ0MyAxODY5NTcyNzYwMDE4ODAgNTA2MjY4NjMxMDkxNjQ5