[ '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:----uxDWvJTRZy3z0Zd8VXj5sDBEN56J+/e521n6kbC26VB8ze8cnoC4FeAcSvFgLf4wpw2Q1OayEpHWWZRBTX9TciWHuM0ZjKlje0KEdY4xVIBt8FWkN4g4VwStjWffgoDF/MwRpu9VrNmKJ1iRvDgPa0auTUO2DBUU/kv4jHlx4ZqMZy8vOluv29Rgn3lyTpYcJt/wT3YLP1fRnS5ZOr+wVsiBKWQQx+Z/ESo8yBtMGM8OaeBP91hebx1SoL+AgNWOyjqOgoNPH75V1eChC3ZcfLdZZ+eVHJJaQlAF8e76ZlQKfFM6pHn8KXnYbFVNXy64CCq0aGp886V6i27TC1lps72Eb2eY70voquqwVagjsjraNQMIadIgSCOzPKhyNRstGsZS+9V2ilQkKC0WfH5O4BKw9HbvyDSZnf67jwjL3E7FvgffjEw0H75OiYMYalbf78UvIVd9wo/gHqnCt7vuUrKzVVK+9VVZOG1SXH7hjYh1b2nl8+2ThI/vjmZAHKnaK0gEAmnjRRnWdVuLr33haZIRLRP8S/h1k1I+ESzfQ21VG9rHFSU8gRlqTBRrpZ+hLU0BL8w7my+sQiBvAAxgLEYxZJk7xAzw22V3kG+icrP2/6mMJG5MFwFWRNtjc37XCQGVAXFmQJZaY/Hsmm2odcbs3NM7rJnl1HJiHaU/TfY=----ATTACHMENT:----NDYxMDE3NDE2NTAxOTk0IDUyNzc4MjAzMTU1ODc2MjYgOTQ3NDM2OTMwNTcyOTQ1NQ==