Sorry, I am still having difficulties with the signature part
I am trying now simply to verify a signature coming from the mastodon.social server.
I get the following request to my server:
curl -v -X POST 'https://smilodon.avocados.ovh/users/paul.fournel/inbox' -H 'accept-encoding: gzip' -H 'content-length: 255' -H 'content-type: application/activity+json' -H 'date: Sat, 25 Mar 2023 17:28:36 GMT' -H 'digest: SHA-256=M8VyaGCFBLezf+6oroKIuzfKr3dCdKuzzcrvwLZO3j8=' -H 'host: smilodon.avocados.ovh' -H 'signature: keyId="https://mastodon.social/users/paul_fournel#main-key",algorithm="rsa-sha256",headers="(request-target) host date digest content-type",signature="Ug+08Q1xIJDuefWM1imdRK/YDuSfD9gzWlQoTj0IEdxNPUoKnqzenzOvzor6Hn/PBIvOYI/ZwLdzaYoJM6eMXOsluviz3E+VxCE65LioyQPtkxh4Q1tKQrcCz9Mt55VRetSfqJuS67dQeINlD4ZxW0R7+/yUjRIrCeqic9umnxjxCSmbQ0E8RYGadOM0HiNPebctq3H3mp1YnPNmoATWL/1mK8C2sP/tNtqrraIQf4cUz/MRJNw33LJuPx0/uwSiBULFEFbUXmewRgXpiCFiY4dpLm3rGjxGjjD9IEyyufQk9DeDNeh9/o6WkRd0/CChA4vUwkg5+arZWKmC6mXFyg=="' -H 'user-agent: http.rb/5.1.1 (Mastodon/4.1.1; +https://mastodon.social/)' -H 'x-forwarded-host: smilodon.avocados.ovh' -H 'x-forwarded-port: 443' -H 'x-forwarded-proto: https' -H 'x-forwarded-scheme: https' -H 'x-real-ip: 141.95.102.40' -H 'x-request-id: e8349274da4aa043a46a8651f6e3cf4c' -H 'x-scheme: https' --data-binary '{"@context":"https://www.w3.org/ns/activitystreams","id":"https://mastodon.social/6c3af211-45f2-4f37-a18b-0349b7871855","type":"Follow","actor":"https://mastodon.social/users/paul_fournel","object":"https://smilodon.avocados.ovh/users/paul.fournel/actor"}'
I want to validate the signature like this in my terminal
openssl dgst -sha256 -verify public.key -signature signature.txt data.txt
I guess I get the data.txt
file wrong
this is what I have in the file:
(request-target): post /users/paul.fournel/inbox\nhost: smilodon.avocados.ovh\ndate: Sat, 25 Mar 2023 17:28:36 GMT\ndigest: SHA-256=M8VyaGCFBLezf+6oroKIuzfKr3dCdKuzzcrvwLZO3j8=\ncontent-type: application/activity+json\n
From the mastodon it looks correct, but I still have `Verification Failure``
I have the feeling that it might be an ordering or a new line problem.
I could also be a problem of string signature encoding. At the moment, I have it in the text file exactly how it comes from the API.
Ug+08Q1xIJDuefWM1imdRK/YDuSfD9gzWlQoTj0IEdxNPUoKnqzenzOvzor6Hn/PBIvOYI/ZwLdzaYoJM6eMXOsluviz3E+VxCE65LioyQPtkxh4Q1tKQrcCz9Mt55VRetSfqJuS67dQeINlD4ZxW0R7+/yUjRIrCeqic9umnxjxCSmbQ0E8RYGadOM0HiNPebctq3H3mp1YnPNmoATWL/1mK8C2sP/tNtqrraIQf4cUz/MRJNw33LJuPx0/uwSiBULFEFbUXmewRgXpiCFiY4dpLm3rGjxGjjD9IEyyufQk9DeDNeh9/o6WkRd0/CChA4vUwkg5+arZWKmC6mXFyg==