Change code to use first usable keypairs record for local user for signing, if it exists (#39662)

This commit is contained in:
Claire authored and GitHub committed 2026-07-01 12:49:42 +00:00
1 parent 68627adff4
commit 7fc19f81aa
14 files changed
+115 -33

No files matched your search

+15 -3
View File
@@ -612,10 +612,22 @@ module Mastodon::CLI
def rotate_keys_for_account(account, delay = 0)
fail_with_message 'No such account' if account.nil?
old_key = account.private_key
old_key = account.keypair
new_key = OpenSSL::PKey::RSA.new(2048)
account.update(private_key: new_key.to_pem, public_key: new_key.public_key.to_pem)
ActivityPub::UpdateDistributionWorker.perform_in(delay, account.id, { 'sign_with' => old_key })
account.update(private_key: nil, public_key: '', keypairs: [account.keypairs.build(local_fragment: '#main-key', type: :rsa, public_key: new_key.public_key.to_pem, private_key: new_key.to_pem)])
ActivityPub::UpdateDistributionWorker.perform_in(
delay,
account.id,
{
'sign_with' => {
'private_key' => old_key.private_key,
'local_fragment' => old_key.local_fragment,
'type' => old_key.type,
},
}
)
end
end
end