Hi,
currently implementing ActivityPub, and testing it against Mastodon, I am banging my head at the HTTP signature not verifying correctly.
Here is what the Mastodon instance replies:
{
'error': 'Verification failed for clitest2@vocatadev.pagekite.me https://vocatadev.pagekite.me/users/clitest2 using rsa-sha256 (RSASSA-PKCS1-v1_5 with SHA-256)',
'signed_string': '(request-target): post /users/pinguin/inbox\nhost: floss.social\ndate: Thu, 13 Apr 2023 12:07:38 GMT\ndigest: SHA-256=3lpN7mh9QKgOz4SJKXrD+hMNS9E7yex+QiJ9aRZ2LB8=',
'signature': 'E1y8Tg7ew5pWFsDJdXOrC5UfbgC0gVct6RJnLx9V44wklimkm3Mry9trNHBJNtvHJnlZID0URpYuDI7NOWb0d6xxP51jmB9oIwzYnlM+IOZNvzfHCEK05NasoVSakeOGbLWUURpjGYzWVPFB+4Ys7/Yw5iTShsgsaP+nvvWasNAkPPQD34IK2Tfin09Pjh5DQGnsITMLjKbzhERVGzGrAFT2msmm6lCUT6JpLVDxmYLB5ewehmWgqKSEt7x9N+8eMcjAdhbMKTEpovrmQDdMs0Gd9edJBrcvopXp6zLvRTFu9/NB1A92DZOIFt2FD8nk2/g46ycJ3Wd/inuz/meDrQ=='
}
And here is my actor as represented when retrieving it over HTTP:
{
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://vocatadev.pagekite.me/users/clitest2",
"type": "Person",
"inbox": "https://vocatadev.pagekite.me/users/clitest2/inbox",
"https://w3id.org/security#publicKey": {
"id": "https://vocatadev.pagekite.me/users/clitest2#aiyPjWeV8bjVQWU5xyZ6qA",
"https://w3id.org/security#owner": "https://vocatadev.pagekite.me/users/clitest2",
"https://w3id.org/security#publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArI46FaB6S35L8UjOuHO3\nAsolH0HNCjeFtbZIYJ2Qf7SrSp6/F4ZHGptNKADe1wt+5Smx7m/clDV5REyR9JXr\naxsEOymeza+ZRkzAXbC4VZNZ+uhk9L2mPlwmTBaF+snjqHW2CsyfSGZ7RdhzPt1I\nk8d4yzoMFxC3p8HTken/zdSQNTRObqFWRSgKf7bOYL6Acpu2mE7aO4AHE/ZVTPoU\nsQ8bm4eBik1MqLDS1Sg+bC7h7ID64sf1w1vNthdqlW8B1kqFocxtO9O/M9jxITcl\n96V0lklvTAn1MHtWlqW2bgTWImQZp55+qhSSleozTQt9jHe89LCFbn4WcCH8jnWz\n9wIDAQAB\n-----END PUBLIC KEY-----\n"
},
"followers": "https://vocatadev.pagekite.me/users/clitest2/followers",
"following": "https://vocatadev.pagekite.me/users/clitest2/following",
"name": "Vocata CLI Test User",
"outbox": "https://vocatadev.pagekite.me/users/clitest2/outbox",
"preferredUsername": "clitest2"
}
I have verified the signature myself both through my own implementation and by stuffing it into the first HTTP signature verification snippet I found on StackOverflow, and both are happy with it ;).
Also, I see Mastodon do all the dereferencing:
INFO: ::ffff:141.95.205.35:0 - "GET /users/clitest2 HTTP/1.1" 200 OK
INFO: ::ffff:141.95.205.35:0 - "GET /users/clitest2 HTTP/1.1" 200 OK
INFO: ::ffff:141.95.205.35:0 - "GET /webfinger?resource=acct:clitest2@vocatadev.pagekite.me HTTP/1.1" 200 OK
INFO: ::ffff:141.95.205.35:0 - "GET /users/clitest2/outbox HTTP/1.1" 200 OK
INFO: ::ffff:141.95.205.35:0 - "GET /users/clitest2/following HTTP/1.1" 200 OK
INFO: ::ffff:141.95.205.35:0 - "GET /users/clitest2/followers HTTP/1.1" 200 OK
INFO: ::ffff:141.95.205.35:0 - "GET /users/clitest2 HTTP/1.1" 200 OK
And if I read mastodon/app/controllers/concerns/signature_verification.rb at af49d93fd6168c089530240a9ab4eccb975b8c42 · mastodon/mastodon · GitHub correctly, the error message means that everything (retrieving actor and key, etc.) was already successful, and what is failing ist the verification of the signature itself.
Any hints on how to debug that, or even what could be the issue?
I might set up my own Mastodon instance and get it to print debug logs…
Thanks,
Nik