summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--application.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/application.rb b/application.rb
index c821876..5353ae4 100644
--- a/application.rb
+++ b/application.rb
@@ -139,12 +139,15 @@ class Application
end
def inbox uri
- http = Net::HTTP.new(uri.host, uri.port)
- http.use_ssl = true
- header = { 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }
- request = Net::HTTP::Get.new(uri.request_uri, header)
- response = http.request(request)
- JSON.parse(response.body)["inbox"]
+ # http = Net::HTTP.new(uri.host, uri.port)
+ # http.use_ssl = true
+ # header = { 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }
+ # request = Net::HTTP::Get.new(uri.request_uri, header)
+ # response = http.request(request)
+ # JSON.parse(response.body)["inbox"]
+ # p uri.host
+ # p get(uri)["inbox"]
+ URI(get(uri)["inbox"]).request_uri
end
def deliver object, urls
@@ -158,7 +161,9 @@ class Application
body = object.to_json
digest = "SHA-256=" + sha256.base64digest(body)
- signed_string = "(request-target): post /inbox\nhost: #{uri.host}\ndate: #{date}\ndigest: #{digest}\ncontent-type: application/activity+json"
+ # signed_string = "(request-target): post /inbox\nhost: #{uri.host}\ndate: #{date}\ndigest: #{digest}\ncontent-type: application/activity+json"
+ p inbox(uri)
+ signed_string = "(request-target): post #{inbox uri}\nhost: #{uri.host}\ndate: #{date}\ndigest: #{digest}\ncontent-type: application/activity+json"
puts signed_string
signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest.new('SHA256'), signed_string))
signed_header = 'keyId="' + ACTOR + '#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="' + signature + '"'