diff options
author | pdp8 <pdp8@pdp8.info> | 2023-05-04 18:22:37 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-05-04 18:22:37 +0200 |
commit | 5036c8e432430096ff5a74303789c1d1387600ec (patch) | |
tree | 454a2ee61d441e6b277171b665bc7e9a762a6756 | |
parent | 7340bf4afb5c0ca8f3d72db8848222508bb8807c (diff) |
remote signature accept
-rw-r--r-- | application.rb | 19 |
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 + '"' |