本地 ActivityPub 角色正在被创建,未附带密钥对

我无法弄清楚如何将任何帖子联合到 Mastodon,我可以很好地关注参与者。当 Discourse 尝试发送帖子时,我在日志中收到以下错误:

[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/a93549c3c7883784eda700f30de0c96b failed to deliver to https://mstdn.party/users/staff/inbox --- !ruby/hash:ActiveSupport::HashWithIn
[Discourse Activity Pub] POST request to https://mastodon.neat.computer/users/jonah/inbox failed: Expected([200, 201, 202]) <=> Actual(401 Unauthorized)
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce failed to deliver to https://mastodon.neat.computer/users/jonah/inbox --- !ruby/hash:ActiveSupport:
[Discourse Activity Pub] POST request to https://mstdn.party/users/staff/inbox failed: Expected([200, 201, 202]) <=> Actual(401 Unauthorized)

我禁用了 Activity pub require signed requests 并启用了设置中的日志记录,否则所有设置都保持默认。这些 Mastodon 实例位于 Cloudflare 后面,但我可以看到 Cloudflare 没有阻止请求,并且 mastodon-web 服务日志显示 Mastodon 本身正在返回 401 代码(尽管我不知道如何增加 Mastodon 日志的详细程度以查看原因)。

有什么原因会导致这种情况发生吗?

编辑:Mastodon 不喜欢 HTTP 签名,尽管此实例没有启用 Authorized Fetch:

Mar 08 16:47:07 neat-mastodon bundle[3119591]: D, [2025-03-08T16:47:07.963455 #3119591] DEBUG -- : [e6b2bc50-09e1-464e-a937-4c43ef32bd99] Signature verification failed: Request not signed
Mar 08 16:47:07 neat-mastodon bundle[3119591]: I, [2025-03-08T16:47:07.964520 #3119591]  INFO -- : [e6b2bc50-09e1-464e-a937-4c43ef32bd99] method=POST path=/users/jonah/inbox format=html controller=ActivityPub::InboxesController action=create status=401 allocations=1256 duration=9.15 view=0.69 db=1.86

编辑 2:似乎我的 Discourse 用户的收件箱无法访问:https://verify.funfedi.dev/?actor_uri=jonah%40discuss.privacyguides.net

    "Resolving acct:jonah@discuss.privacyguides.net using webfinger",
    "Resolved to https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce",
    "Running verification for alice",
    "Got inbox None", [...]

确实像预期的那样适用于群组参与者:https://verify.funfedi.dev/?actor_uri=articles%40discuss.privacyguides.net :thinking:

编辑 3:对于 GET 请求到 https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce

{
    "id": "https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce",
    "type": "Person",
    "updated": "2025-03-08T06:34:19Z",
    "url": "https://discuss.privacyguides.net/u/jonah",
    "name": "Jonah Aragon",
    "inbox": null,
    "outbox": null,
    "sharedInbox": "https://discuss.privacyguides.net/ap/users/inbox",
    "followers": "https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce/followers",
    "preferredUsername": "jonah",
    "icon": {
        "type": "Image",
        "mediaType": "image/png",
        "url": "https://forum-cdn.privacyguides.net/user_avatar/discuss.privacyguides.net/jonah/96/8151_2.png"
    },
    "@context": "https://www.w3.org/ns/activitystreams"
}

@JonahAragon1,让我们看看是否能弄清楚。\n\n[quote="Jonah Aragon, post:1, topic:356834, username:JonahAragon1"]\n我禁用了 Activity pub require signed requests\n[/quote]\n\n您是在测试之前还是之后禁用的?如果是之前,请尝试启用它。\n\n更广泛地说,我一直想添加更好的错误响应消息日志记录,以便更容易诊断不同的情况。为此,我提出了一个 PR\n\nhttps://github.com/discourse/discourse-activity-pub/pull/187\n\n合并后,如果您能再试一次,并分享相同的日志。

1 个赞

我现在已重新启用此设置,因为我已确定问题在于用户收件箱未创建。我现在将更新插件 :+1:

Person Actors of Discourse Users 目前不应拥有单独的收件箱。Mastodon 使用并理解 sharedInbox。还有其他事情在发生。

除了日志记录外,所有设置都已恢复为默认值:

[Discourse Activity Pub] POST 请求到 https://mastodon.neat.computer/users/jonah/inbox 失败:{"error":"Request not signed"}
回溯
activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:130:in `block in warn'

activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:231:in `block in dispatch'

activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:231:in `each'

activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:231:in `dispatch'

activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:130:in `warn'

/var/www/discourse/plugins/discourse-activity-pub/lib/discourse_activity_pub/logger.rb:26:in `log'

/var/www/discourse/plugins/discourse-activity-pub/lib/discourse_activity_pub/logger.rb:63:in `warn'

/var/www/discourse/plugins/discourse-activity-pub/lib/discourse_activity_pub/request.rb:66:in `rescue in perform'

/var/www/discourse/plugins/discourse-activity-pub/lib/discourse_activity_pub/request.rb:48:in `perform'

/var/www/discourse/plugins/discourse-activity-pub/lib/discourse_activity_pub/request.rb:44:in `post_json_ld'

/var/www/discourse/plugins/discourse-activity-pub/app/jobs/discourse_activity_pub_deliver.rb:34:in `perform_request'

/var/www/discourse/plugins/discourse-activity-pub/app/jobs/discourse_activity_pub_deliver.rb:15:in `execute'

/var/www/discourse/app/jobs/base.rb:316:in `block (2 levels) in perform'

rails_multisite-6.1.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
rails_multisite-6.1.0/lib/rails_multisite/connection_management.rb:21:in `with_connection'
/var/www/discourse/app/jobs/base.rb:303:in `block in perform'

/var/www/discourse/app/jobs/base.rb:299:in `each'

/var/www/discourse/app/jobs/base.rb:299:in `perform'

sidekiq-7.3.9/lib/sidekiq/processor.rb:220:in `execute_job'

sidekiq-7.3.9/lib/sidekiq/processor.rb:185:in `block (4 levels) in process'

sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:180:in `traverse'

sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'

/var/www/discourse/lib/sidekiq/pausable.rb:132:in `call'

sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:182:in `traverse'

sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'

sidekiq-7.3.9/lib/sidekiq/job/interrupt_handler.rb:9:in `call'

sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:182:in `traverse'

sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'

sidekiq-7.3.9/lib/sidekiq/metrics/tracking.rb:26:in `track'

sidekiq-7.3.9/lib/sidekiq/metrics/tracking.rb:134:in `call'

sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:182:in `traverse'

sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:173:in `invoke'

sidekiq-7.3.9/lib/sidekiq/processor.rb:184:in `block (3 levels) in process'

sidekiq-7.3.9/lib/sidekiq/processor.rb:145:in `block (6 levels) in dispatch'

sidekiq-7.3.9/lib/sidekiq/job_retry.rb:118:in `local'

sidekiq-7.3.9/lib/sidekiq/processor.rb:144:in `block (5 levels) in dispatch'

sidekiq-7.3.9/lib/sidekiq/config.rb:39:in `block in <class:Config>'

sidekiq-7.3.9/lib/sidekiq/processor.rb:139:in `block (4 levels) in dispatch'

sidekiq-7.3.9/lib/sidekiq/processor.rb:281:in `stats'

sidekiq-7.3.9/lib/sidekiq/processor.rb:134:in `block (3 levels) in dispatch'

sidekiq-7.3.9/lib/sidekiq/job_logger.rb:15:in `call'

sidekiq-7.3.9/lib/sidekiq/processor.rb:133:in `block (2 levels) in dispatch'

sidekiq-7.3.9/lib/sidekiq/job_retry.rb:85:in `global'

sidekiq-7.3.9/lib/sidekiq/processor.rb:132:in `block in dispatch'

sidekiq-7.3.9/lib/sidekiq/job_logger.rb:40:in `prepare'

sidekiq-7.3.9/lib/sidekiq/processor.rb:131:in `dispatch'

sidekiq-7.3.9/lib/sidekiq/processor.rb:183:in `block (2 levels) in process'

sidekiq-7.3.9/lib/sidekiq/processor.rb:182:in `handle_interrupt'

sidekiq-7.3.9/lib/sidekiq/processor.rb:182:in `block in process'

sidekiq-7.3.9/lib/sidekiq/processor.rb:181:in `handle_interrupt'

sidekiq-7.3.9/lib/sidekiq/processor.rb:181:in `process'

sidekiq-7.3.9/lib/sidekiq/processor.rb:86:in `process_one'

sidekiq-7.3.9/lib/sidekiq/processor.rb:76:in `run'

sidekiq-7.3.9/lib/sidekiq/component.rb:10:in `watchdog'

sidekiq-7.3.9/lib/sidekiq/component.rb:19:in `block in safe_thread'

嘿,看起来 Mastodon 的问题在于请求未签名。

您确定该日志条目是在您重新启用“Activity pub require signed requests”之后创建的吗?

是的,没错。

抱歉催促,但 Mastodon 在请求头中完全没有签名时会返回此错误,因此在发送请求时启用 Activity pub require signed requests 的可能性似乎不大。您能否触发一个全新的 POST 请求。

啊,我认为问题在于Cloudflare正在从请求中剥离标头。

1 个赞

是的,这是默认设置且启用了该设置时的错误。

[Discourse Activity Pub] POST 请求到 https://mstdn.party/users/staff/inbox 失败:{"error":"Request not signed"}
10:40 am
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 无法发送到 https://mstdn.party/users/staff/inbox --- !ruby/hash:ActiveSupport::HashWithIn
10:40 am
[Discourse Activity Pub] POST 请求到 https://mastodon.neat.computer/users/jonah/inbox 失败:{"error":"Request not signed"}
10:40 am
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 无法发送到 https://mastodon.neat.computer/users/jonah/inbox --- !ruby/hash:ActiveSupport::
10:40 am
[Discourse Activity Pub] POST 请求到 https://social.lol/users/jonah/inbox 失败:{"error":"Request not signed"}
10:40 am
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 无法发送到 https://social.lol/users/jonah/inbox --- !ruby/hash:ActiveSupport::HashWithInd

(我注意到 social.lol 和论坛都不在 Cloudflare 后面)

编辑:如果您想从您知道可以正常工作的 Mastodon 帐户关注 @videos@discuss.privacyguides.net,请告诉我,我可以从论坛重新发送帖子。

好的,请用那位演员创建一篇新帖子。

您是否正确收到了帖子?看起来您可能收到了。

 2
[Discourse Activity Pub] 发送 POST 请求至 https://angus.ngrok.io/ap/actor/0eafb34c67153d61db44234de294a98d/inbox 失败:{"errors":["Request not signed"]}
上午 10:56
2
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://angus.ngrok.io/ap/actor/0eafb34c67153d61db44234de294a98d/inbox --- !ru
上午 10:56
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/705b7513d0446e001d7f750115e6395f 已成功发送至 https://mstdn.party/users/staff/inbox --- !ruby/hash:ActiveSupport::HashW
上午 11:00
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/705b7513d0446e001d7f750115e6395f 已成功发送至 https://social.lol/users/jonah/inbox --- !ruby/hash:ActiveSupport::HashWi
上午 11:00
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/705b7513d0446e001d7f750115e6395f 已成功发送至 https://mastodon.neat.computer/users/jonah/inbox --- !ruby/hash:ActiveSup
上午 11:00
3
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://mstdn.party/users/staff/inbox --- !ruby/hash:ActiveSupport::HashWithIn
上午 11:01
3
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://social.lol/users/jonah/inbox --- !ruby/hash:ActiveSupport::HashWithInd
上午 11:01
3
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://mastodon.neat.computer/users/jonah/inbox --- !ruby/hash:ActiveSupport:
上午 11:01
2
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://mstdn.party/users/staff/inbox --- !ruby/hash:ActiveSupport::HashWithIn
上午 11:01
2
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://mastodon.neat.computer/users/jonah/inbox --- !ruby/hash:ActiveSupport:
上午 11:01
2
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://social.lol/users/jonah/inbox --- !ruby/hash:ActiveSupport::HashWithInd
上午 11:01
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 已成功发送至 https://angus.ngrok.io/ap/actor/0eafb34c67153d61db44234de294a98d/inbox --
上午 11:01
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 已成功发送至 https://angus.ngrok.io/ap/actor/0eafb34c67153d61db44234de294a98d/inbox --
上午 11:01
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/705b7513d0446e001d7f750115e6395f 已成功发送至 https://angus.ngrok.io/ap/actor/0eafb34c67153d61db44234de294a98d/inbox --
上午 11:01
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/a93549c3c7883784eda700f30de0c96b 已成功发送至 https://angus.ngrok.io/ap/actor/0eafb34c67153d61db44234de294a98d/inbox --
上午 11:02
2
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/a93549c3c7883784eda700f30de0c96b 未能成功发送至 https://mstdn.party/users/staff/inbox --- !ruby/hash:ActiveSupport::HashWithIn
上午 11:02
2
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/a93549c3c7883784eda700f30de0c96b 未能成功发送至 https://mastodon.neat.computer/users/jonah/inbox --- !ruby/hash:ActiveSupport:
上午 11:02
2
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/a93549c3c7883784eda700f30de0c96b 未能成功发送至 https://social.lol/users/jonah/inbox --- !ruby/hash:ActiveSupport::HashWithInd
上午 11:02
15
[Discourse Activity Pub] 发送 POST 请求至 https://mastodon.neat.computer/users/jonah/inbox 失败:{"error":"Request not signed"}
上午 11:02
12
[Discourse Activity Pub] 发送 POST 请求至 https://social.lol/users/jonah/inbox 失败:{"error":"Request not signed"}
上午 11:02
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://mastodon.neat.computer/users/jonah/inbox --- !ruby/hash:ActiveSupport:
上午 11:02
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://social.lol/users/jonah/inbox --- !ruby/hash:ActiveSupport::HashWithInd
上午 11:02
[Discourse Activity Pub] 发送 POST 请求至 https://angus.ngrok.io/ap/actor/0eafb34c67153d61db44234de294a98d/inbox 失败:The endpoint angus.ngrok.io is offline. ERR_NGROK_3200
上午 11:02
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://angus.ngrok.io/ap/actor/0eafb34c67153d61db44234de294a98d/inbox --- !ru
上午 11:02
16
[Discourse Activity Pub] 发送 POST 请求至 https://mstdn.party/users/staff/inbox 失败:{"error":"Request not signed"}
上午 11:02
2
[Discourse Activity Pub] https://discuss.privacyguides.net/ap/actor/227cc2ddaa4ded69c2a58214031da3ce 未能成功发送至 https://mstdn.party/users/staff/inbox --- !ruby/hash:ActiveSupport::HashWithIn
上午 11:02 

请注意,我和 @JonahAragon1 在聊天中讨论过这个问题,问题在于本地用户 Actor 在某种程度上被创建时没有密钥对。

@JonahAragon1 我会测试一些东西然后回复你。

1 个赞

@JonahAragon1

你论坛上的这些用户之间有什么区别吗?有什么你觉得值得注意的吗?

ShampooBhaelros 创建了密钥,但为 basenotejonah 没有。你网站上这两组用户之间有什么常见的区别吗?

嗯,不是的。我找不到任何原因。虽然 jonah 是管理员,但其他人都是普通用户。

杂项

Bhaelrosbasenote 都是信任等级 3 的常规用户,所以他们应该是一样的。

奇怪的是 Shampoo 也生成了收件箱/发件箱,而 basenotejonah 没有,那么 ensure_keysensure_inbox_and_outbox 都没有起作用吗?:

GET https://discuss.privacyguides.net/ap/actor/310a0986b6bf613b61ca5e85a8521ecb

{
    "id": "https://discuss.privacyguides.net/ap/actor/310a0986b6bf613b61ca5e85a8521ecb",
    "type": "Person",
    "updated": "2025-03-11T17:58:08Z",
    "url": "https://discuss.privacyguides.net/u/Shampoo",
    "inbox": "https://discuss.privacyguides.net/ap/actor/310a0986b6bf613b61ca5e85a8521ecb/inbox",
    "outbox": "https://discuss.privacyguides.net/ap/actor/310a0986b6bf613b61ca5e85a8521ecb/outbox",
    "sharedInbox": "https://discuss.privacyguides.net/ap/users/inbox",
    "followers": "https://discuss.privacyguides.net/ap/actor/310a0986b6bf613b61ca5e85a8521ecb/followers",
    "preferredUsername": "Shampoo",
    "publicKey": {
        "id": "https://discuss.privacyguides.net/ap/actor/310a0986b6bf613b61ca5e85a8521ecb#main-key",
        "owner": "https://discuss.privacyguides.net/ap/actor/310a0986b6bf613b61ca5e85a8521ecb",
        "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAleqeCRZW1utTN/L5GjkY\n+2Baron4FnSKRMKW70IWfqI4rs8dfh2xhKW5qXxaBPhXf13FAOJvQvFhQ90eqRrn\nKkuMsntZN0dfpDUZ3E0iIp8fuUEVk2PmquLziiy9+zu8n5ak65lJKDYnKVtFth5G\nFJyUt6GYicY8UlUh6dPxafJ/gw6YTlvT3hO0X0H0L+hYwqHJpppl6niSDi6WQzME\nWM1hyBpv2Y2NspEexrkSVh+SIR3nJ8J1R+o+2bLJ4Hl34nYhtNyTy9AOddoQYDMw\nICZAkCLQDweid50fGakWmRB5EXfL6s2EdzEh8MOE7cyCOXgFrxTJYUTwg5TiLEQY\npQIDAQAB\n-----END PUBLIC KEY-----\n"
    },
    "icon": {
        "type": "Image",
        "mediaType": "image/png",
        "url": "https://forum-cdn.privacyguides.net/user_avatar/discuss.privacyguides.net/shampoo/96/4073_2.png"
    },
    "@context": "https://www.w3.org/ns/activitystreams"
}

GET https://discuss.privacyguides.net/ap/actor/a93549c3c7883784eda700f30de0c96b

{
    "id": "https://discuss.privacyguides.net/ap/actor/a93549c3c7883784eda700f30de0c96b",
    "type": "Person",
    "updated": "2025-03-08T06:34:19Z",
    "url": "https://discuss.privacyguides.net/u/basenote",
    "inbox": null,
    "outbox": null,
    "sharedInbox": "https://discuss.privacyguides.net/ap/users/inbox",
    "followers": "https://discuss.privacyguides.net/ap/actor/a93549c3c7883784eda700f30de0c96b/followers",
    "preferredUsername": "basenote",
    "icon": {
        "type": "Image",
        "mediaType": "image/png",
        "url": "https://forum-cdn.privacyguides.net/user_avatar/discuss.privacyguides.net/basenote/96/15_2.png"
    },
    "@context": "https://www.w3.org/ns/activitystreams"
}

我仍然不确定这些参与者是如何陷入这种状态的。这特定于您的站点。总的来说,参与者密钥和收件箱/发件箱的创建按预期工作。不过,此更新应确保此类情况得到解决:

1 个赞

@JonahAragon1 PR 已合并。您能否尝试更新并告知我进展?

1 个赞

这个特定问题似乎已得到修复,尽管我仍然在获取帖子显示在 Mastodon 上时遇到一般性问题。

你能提供更多细节吗?

是的,我本周晚些时候会回复或发新帖,我现在暂时不在。\n\n我看到的主要问题是帖子没有显示为类别 actor 的 boost(有时我可以通过手动搜索用户 actor 在 Mastodon 上找到它们),以及论坛帖子根本没有发布到 AP。\n\n我现在也难以关注新的类别 actor,这以前不是问题。如果我在 这里 查看,它显示关注者下没有找到结果。\n\n我注意到 Meta 上 AP 启用的类别中的许多帖子都显示了它们未发布到 AP 的指示(就像这篇帖子一样),所以也许我只是不明白这应该如何工作……\n\n我在日志中没有看到任何明显的错误,你会认为一切都正常工作,因为日志通知是成功的。这些都是我以后有时间需要进一步研究的问题。