fix(federation): rotate relay keys on startup if missing private keys

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-06-06 12:20:35 +02:00
parent 6745590e54
commit 5381eaae22
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
1 changed files with 7 additions and 1 deletions

View File

@ -23,7 +23,13 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
def init do
# Wait for everything to settle.
Process.sleep(1000 * 5)
get_actor()
relay = get_actor()
unless Regex.match?(~r/BEGIN RSA PRIVATE KEY/, relay.keys) do
{:ok, relay} = Actors.actor_key_rotation(relay)
end
relay
end
@spec get_actor() :: Actor.t() | no_return