diff options
author | pdp8 <pdp8@pdp8.info> | 2023-04-23 02:37:14 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-04-23 02:37:14 +0200 |
commit | f8afb7dec94bf9248b4032b7e95549361f190f3c (patch) | |
tree | 5a13b87f674ad87e7b325c16da7edd5e612442cc /post.rb |
initial import
Diffstat (limited to 'post.rb')
-rw-r--r-- | post.rb | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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) |