[ '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 = new RSA(); $rsa->loadKey( file_get_contents( dirname(__DIR__, 2) . '/WebServer/distant/keys/private.pem' ) ); // private key $plaintext = "(request-target) post $path\nhost: $host\ndate: $date"; $rsa->setHash("sha256"); $rsa->setSignatureMode(RSA::SIGNATURE_PSS); $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:----cfRxvz+dUFejjQxQEbb1U1GQc/PxmrtHMMESmnguORpcyKIefulLMe/lyl2WT1D5SvD953hrIVd0AP9Zmime5qGnAwW2ySH8RFqfHw0Dbx7F9zpxPdx20YwbV5x6s/jm1ff4h8sQpxrEVf3BrNhQdNLx83KaPQbxGyD5s8eoZu2q+SNvQwG91OVCxEsl2VuorNyPtobK0mDsdxbv+UkEYl73UrD/Y2/YODTZWsvi10j0f840BJzB/0673EPxg4C/nJCv4h090TXeI6A0FpRW14AEzhtcgj/5xOZyGUAdMZy5HZIWdRyusH7J8ocfir1S/DV2ncbnEYtaFE/NsxDqfh5d6Kc9mfDTcb3CB+TQjyaZ5AUNY4cwrfbbRKc/ddeNFI/3MYlnOk7UNOWoGNu/a1SeqXLru/KJ3XhSJnQI56rwaDFH+Cv1ykISNFzCOlmnSm7MBB259QF6ZKllDKwGcOhkbgrwgtaQ1q994yVKrbt70e6P8PdDhqZVIzrcuxwbdltwB/GjosxHurLMam0rArZTT7Rt+ZvsWdD3K7DjgCKNT8sG9dpc7H+AszteBnpeW2EKqQ/aLza1f0/MB5lI0S80TtxXh97W0CvyGvmTuwEEYHbmBccYazW7kvILxNxRARtxhIhPezsnPgoy3H/eICY3PUpPq/c1ooGvZ+QUBIE=----ATTACHMENT:----MTYxNjYyODUxNTU0MjE3MCAzNjcyOTQ0NTA0MjEwMTQ1IDkzMTYwOTQwNTYwMzkxMg==