diff options
-rw-r--r-- | deliver.rb | 14 | ||||
-rw-r--r-- | message | 14 | ||||
-rw-r--r-- | private.pem | 27 |
3 files changed, 55 insertions, 0 deletions
diff --git a/deliver.rb b/deliver.rb new file mode 100644 index 0000000..3a46051 --- /dev/null +++ b/deliver.rb @@ -0,0 +1,14 @@ +# https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/ + +require 'http' +require 'openssl' + +document = File.read('message') +date = Time.now.utc.httpdate +keypair = OpenSSL::PKey::RSA.new(File.read('private.pem')) +signed_string = "(request-target): post /inbox\nhost: git.exozy.me\ndate: #{date}" +signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest::SHA256.new, signed_string)) +header = 'keyId="https://test.exozy.me/api/v1/activitypub/user/test#main-key",headers="(request-target) host date",signature="' + signature + '"' + +HTTP.headers({ 'Host': 'mastodon.social', 'Date': date, 'Signature': header }) + .post('https://git.exozy.me/api/v1/activitypub/user/Ta180m/inbox', body: document) @@ -0,0 +1,14 @@ +{ + "@context": "https://www.w3.org/ns/activitystreams", + "type": "Note", + "attributedTo": "https://test.exozy.me/api/v1/activitypub/user/test", + "context": "https://git.exozy.me/Ta180m/Hello-world/issues/2", + "inReplyTo": "https://git.exozy.me/Ta180m/Hello-world/issues/2", + "mediaType": "text/html", + "content": "<p>Hello from test.exozy.me!</p>", + "source": { + "mediaType": "text/markdown; variant=Commonmark", + "content": "Hello from test.exozy.me!" + }, + "published": "2019-11-06T20:49:05.604488Z" +} diff --git a/private.pem b/private.pem new file mode 100644 index 0000000..578b7db --- /dev/null +++ b/private.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAsPQH/jssyJryAX9I065SZE69e5OIBW3q2nFjMBDlC+WStN2P +uJqFznsEcEMq9Ge3pTQ3Rqj2SumyqngwYhN63SpFjeplgvL20ygNfd5c4sVwZicn +aLAsjwcWS/7hF6ENW9Vhwk5yBYel7efxPaNY98XhPLVDYeX8ZfB8PK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