Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.63 KB | None | 0 0
  1. require 'http'
  2. require 'openssl'
  3.  
  4. document      = File.read('create-hello-world.json')
  5. date          = Time.now.utc.httpdate
  6. keypair       = OpenSSL::PKey::RSA.new(File.read('private.pem'))
  7. signed_string = "(request-target): post /inbox\nhost: mastodon.social\ndate: #{date}"
  8. signature     = Base64.strict_encode64(keypair.sign(OpenSSL::Digest::SHA256.new, signed_string))
  9. header        = 'keyId="https://my-example.com/actor",headers="(request-target) host date",signature="' + signature + '"'
  10.  
  11. HTTP.headers({ 'Host': 'mastodon.social', 'Date': date, 'Signature': header })
  12.     .post('https://mastodon.social/inbox', body: document)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement