From f8afb7dec94bf9248b4032b7e95549361f190f3c Mon Sep 17 00:00:00 2001 From: pdp8 Date: Sun, 23 Apr 2023 02:37:14 +0200 Subject: initial import --- post.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 post.rb (limited to 'post.rb') diff --git a/post.rb b/post.rb new file mode 100644 index 0000000..dc881b1 --- /dev/null +++ b/post.rb @@ -0,0 +1,12 @@ +require 'http' +require 'openssl' + +document = File.read('create-hello-world.json') +date = Time.now.utc.httpdate +keypair = OpenSSL::PKey::RSA.new(File.read('private.pem')) +signed_string = "(request-target): post /inbox\nhost: mastodon.social\ndate: #{date}" +signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest::SHA256.new, signed_string)) +header = 'keyId="https://my-example.com/actor",headers="(request-target) host date",signature="' + signature + '"' + +HTTP.headers({ 'Host': 'mastodon.social', 'Date': date, 'Signature': header }) + .post('https://mastodon.social/inbox', body: document) -- cgit v1.2.3