I’m trying to use the Mastodon blog posts as a guide for a dead simple federated ActivityPub server. Like many others on this forum, I am running into HTTP Signature problems that I can’t quite figure out despite lots of debugging efforts. Lots of print statements in mastodon later, I’ve figured out quite a bit but am still not succeeding.
The following is the HTTP Request I’m making:
{'_body_position': None,
'_cookies': <RequestsCookieJar[]>,
'body': '{"@context": "https://www.w3.org/ns/activitystreams", "id": '
'"http://9462-75-164-4-199.ngrok-free.app/my-first-follow", "type": '
'"Follow", "actor": '
'"http://9462-75-164-4-199.ngrok-free.app/@ddsdafdSAF", "object": '
'"http://127.0.0.1:3000/@railsadmin"}',
'headers': {'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Digest': 'sha-256=0t+aD34XYYFOwkI9gqNPVDAJUafDUS0UyMS7GJFoEtU=', 'Host': '127.0.0.1:3000', 'Date': 'Mon, 01 Jan 2024 22:05:36 GMT', 'Signature': 'keyId="http://9462-75-164-4-199.ngrok-free.app/@ddsdafdSAF#main-key",headers="(request-target) digest host date",signature="dvFPKwwL9aGZ3uKHvY2j4z0qgpLn/QohoTm3NNzJSxyZnRCSNgIIwH2jJDwpw96vfVQ49lsYBZNN1b5qqSwqsnVu/FsAZhFpj1+kpQtUNtzcmSDkmDDnaKmiGwFWUYrp0IC0QkZrOB73QBIIo4Ovyfd+9veVMGTTP0+AsCl8QwD7Mjw+HIM7M5d8Dclvj0kQ+XAwJrGsbFxGOQBdayMetxYw1KKvjyaQz71LOCfU4C1SqD9NmB9I96dWz6N0PIkyPwI4UD8ZBF6mLCpdk9AqNIZI8mgAYV8TQu2t6FUdHa0SaQ4OgOpfuAU61HhKXy7ocVjn0z8II83xOlleADMkL2dtNKHZLblIoDdq0Xyu7KW0zvL36UlAGbPTsqyn351y7/xajztJ6dM1eemoAmB3GQs590aK6xfCBieYXivxQvm7fGhVwcNn4NjpAlnrS23/BfBb7Vl6pg85XzRvP7hN2pST9QcTk8DNT+AyL1WkCHVCvJaHaZsseIQ6w9gII7ABjOThRRsE2+G2zO5sx5J+mXeysh9HdxfdubDLUW9mNrB5vxLQD1vzY+GC3uTMNq+gWBOkgi4fwID09ZlcJj6+iw1vOr9cPgTzYBjn3JQOAwzqVERJ7ZClI72Qz6IIwPLSMs/NCYeETbHudEUXpFFhheEoeZALdVeXSp32ILxP3BQ="', 'Content-Length': '247'},
'hooks': {'response': []},
'method': 'POST',
'url': 'http://127.0.0.1:3000/inbox'}
Back from Mastodon, I get
>>> pprint.pprint(_)
(b'{"error":"Verification failed for ddsdafdSAF@9462-75-164-4-199.ngrok-free.ap'
b'p http://9462-75-164-4-199.ngrok-free.app/@ddsdafdSAF using rsa-sha256 (RSAS'
b'SA-PKCS1-v1_5 with SHA-256)","signed_string":"(request-target): post /in'
b'box\\ndigest: sha-256=0t+aD34XYYFOwkI9gqNPVDAJUafDUS0UyMS7GJFoEtU=\\nhost:'
b' 127.0.0.1:3000\\ndate: Mon, 01 Jan 2024 22:05:36 GMT","signature":"dvFPK'
b'wwL9aGZ3uKHvY2j4z0qgpLn/QohoTm3NNzJSxyZnRCSNgIIwH2jJDwpw96vfVQ49lsYBZNN1b5qq'
b'SwqsnVu/FsAZhFpj1+kpQtUNtzcmSDkmDDnaKmiGwFWUYrp0IC0QkZrOB73QBIIo4Ovyfd+9veVM'
b'GTTP0+AsCl8QwD7Mjw+HIM7M5d8Dclvj0kQ+XAwJrGsbFxGOQBdayMetxYw1KKvjyaQz71LOCfU4'
b'C1SqD9NmB9I96dWz6N0PIkyPwI4UD8ZBF6mLCpdk9AqNIZI8mgAYV8TQu2t6FUdHa0SaQ4OgOpfu'
b'AU61HhKXy7ocVjn0z8II83xOlleADMkL2dtNKHZLblIoDdq0Xyu7KW0zvL36UlAGbPTsqyn351y7'
b'/xajztJ6dM1eemoAmB3GQs590aK6xfCBieYXivxQvm7fGhVwcNn4NjpAlnrS23/BfBb7Vl6pg85X'
b'zRvP7hN2pST9QcTk8DNT+AyL1WkCHVCvJaHaZsseIQ6w9gII7ABjOThRRsE2+G2zO5sx5J+mXeys'
b'h9HdxfdubDLUW9mNrB5vxLQD1vzY+GC3uTMNq+gWBOkgi4fwID09ZlcJj6+iw1vOr9cPgTzYBjn3'
b'JQOAwzqVERJ7ZClI72Qz6IIwPLSMs/NCYeETbHudEUXpFFhheEoeZALdVeXSp32ILxP3BQ="}')
However, when I paste the private key and public key into Online HTTP Signature tool, I get the exact same signature as I’m sending from python.
When I add print statements to mastodon, I can confirm my digest is alright and it’s truly failing at verification. When I print out compare_signed_string
, and paste those results into the httpsig tool, I get the same signature that my python code is calculating.
I see mastodon correctly downloading my actor/doing a Webfinger and those are succeeding.
What am I missing? What is Mastodon expecting in this request that I am not providing?