aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2019-02-21 08:20:06 +0000
committerlambda <pleromagit@rogerbraun.net>2019-02-21 08:20:06 +0000
commit2813f28b6fa1618efb01f4bd570e055ca16efbc5 (patch)
treee32b0625adda1b70bb8117bf3a1f701f8ff73eeb /lib
parent19bd799bd705bfe8829f0510931f6683de107752 (diff)
parentf8a72f299719d3999c02f2222076906e4b59534d (diff)
downloadpleroma-2813f28b6fa1618efb01f4bd570e055ca16efbc5.tar.gz
Merge branch 'bugfix/httpsig-sign-date' into 'develop'
activitypub: sign date header Closes #649 and #364 See merge request pleroma/pleroma!847
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index d1ac8172e..7e153f396 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -823,11 +823,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
digest = "SHA-256=" <> (:crypto.hash(:sha256, json) |> Base.encode64())
+ date =
+ NaiveDateTime.utc_now()
+ |> Timex.format!("{WDshort}, {D} {Mshort} {YYYY} {h24}:{m}:{s} GMT")
+
signature =
Pleroma.Web.HTTPSignatures.sign(actor, %{
host: host,
"content-length": byte_size(json),
- digest: digest
+ digest: digest,
+ date: date
})
with {:ok, %{status: code}} when code in 200..299 <-
@@ -837,6 +842,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
json,
[
{"Content-Type", "application/activity+json"},
+ {"Date", date},
{"signature", signature},
{"digest", digest}
]