Protecting and rotating Synapse signing keys

Learn why the Synapse signing key underpins federation trust, how to back it up and rotate it safely, and how old_signing_keys keeps past events verifiable.

On this page

Why protecting the Synapse signing key comes before federation opens

The Synapse signing key is the private key that proves your homeserver is who it says it is to every other server on the Matrix federation. Synapse uses it to sign the server keys it publishes and the events it creates, so other homeservers can check that a message really came from your server and was not altered. On first start, Synapse generates this key and writes it to a local file, typically named after your server name with a .signing.key suffix in the data directory you configured. Treat that file as the server's identity, not as a cache that can be regenerated. If it is lost, other servers no longer recognize your server's signatures as coming from the same identity, and that trust cannot be rebuilt by simply restarting Synapse.

This is why the key has to be protected before federation opens. Once your server has joined rooms with other servers, events it signed are part of history that remote servers keep verifying. Losing the key or replacing it carelessly can break that verification for past events and for the server's standing in shared rooms. Plan the key handling as part of go-live, alongside your federation policy and the federation_domain_whitelist decision, rather than after users have started talking to other servers.

Read this page before you go live, before you migrate the homeserver to a new host or volume, and before you rotate any key. Each of those moments can lose or duplicate the key file. Confirm with your Synapse version's documentation exactly where the key file is written in your deployment method, including containers and the ESS Helm chart, and who in your team is responsible for its backup. The sections that follow cover the backup routine, what happens on loss or rotation, and how the old signing key settings keep past events verifiable.

How a signing key moves from creation through backup, loss or rotation

The homeserver generates its signing key the first time Synapse starts, and that key then signs every event it sends to other servers. The diagram shows the key being copied to a separate secured store, then two branches: restoring from that backup after loss, or planned rotation, where the new key is published and the previous key is kept as an old signing key so past events stay verifiable. Check that the backup exists and is restorable before any change is made, and confirm the old key is listed in old_signing_keys after a rotation.

Signing key lifecycle from first start through backup, loss and planned rotation.

Key handling options and when each fits

This table compares four ways to store and recover the Synapse signing key, along with the main risk and the question to settle with the team that runs the server. Read each row as a fallback or a complement to the others, since most deployments combine an encrypted backup with a planned rotation path.

OptionWhen it fitsMain riskWhat to confirm with the operator team
Key kept only on the homeserver hostSmall single-host deployments with a tested host rebuild procedure and no other copy of the keyLoss of the host or its disk means the key is gone, and a new key breaks trust in past signaturesWhere the signing key file sits, who can read it, and whether the host backup includes it
Encrypted offline backup in a vaultTeams that want a recovery copy independent of the host and can restore it under change controlBackup copies drift from the live key, or the vault passphrase is lost along with the keyWho holds the decryption material, how often the backup is checked against the live file, and the restore steps
Key held in a secrets managerOrganizations that already run a managed secrets service with access logging and role-based accessKey is exposed to anyone with broad read access to the vault, and the host may fetch it at startupWhich identities can read the key, whether reads are logged, and how the host gets the key without writing it to disk
Planned rotation with old_signing_keysDeployments that must retire a key on a schedule or after suspected exposure while keeping past events verifiableRotation done carelessly leaves old keys missing from config, so older events stop validating for other serversWhether the old key is listed in old_signing_keys before the new key goes live, and who signs off the change
Restore from backup after key lossRecovery planning for hosts that fail or are rebuiltRestoring an outdated key or mixing keys from different backups creates confusing federation errorsBackup date stamps, which key identifiers the server publishes, and a documented test restore

What happens when the key is lost versus rotated

If the signing key file is gone and no copy exists, the server has lost the private key behind every event it has signed. Synapse may generate a new key at the configured path when the file is missing, so a restart can quietly give the server a different signing identity. Confirm this behavior for your version before you rely on it.

  • Trust with other servers: Remote servers that cached your old public key will not accept signatures made with the new key until they fetch it, and some may stop trusting your events.
  • Cached keys elsewhere: Other homeservers hold the old public key for a period you do not control, so the break can persist after you fix your side.
  • Older events: Events signed by the lost key may no longer be checkable against any key you can publish, so historic verification can fail on other servers.
  • Recovery path: A lost private key cannot be regenerated to match the old one, so your options depend on your version and setup. Confirm them in the upgrade notes and with your Element contact if you have one.

Check now whether your key file is backed up in a second location and whether that backup has been tested by restoring it to a separate host.

How old_signing_keys keeps past events verifiable after rotation

The old_signing_keys setting exists so that a Synapse server can change its signing key without making its earlier events unverifiable. Every event a homeserver sends is signed with its current signing key, and other servers check those signatures against the public keys they have fetched for that server name. Once the key is replaced, a remote server that still holds an event signed by the previous key needs a way to confirm that the old key really belonged to your server. The old_signing_keys block in the Synapse configuration manual is the mechanism for publishing retired keys alongside the current one, so past events can still be checked after rotation.

Your responsibility is to keep every retired key available for as long as the events it signed still matter to someone. In practice that means the old key material must stay in the configuration (or the file it references) for the whole period in which those events may be fetched, replayed, audited or disputed by other servers. Removing a retired key early can leave history from your server unverifiable, while keeping one forever adds a long-lived secret that must be protected like the current key. Decide the retention period with your compliance and legal owners before the first rotation, and record it next to your signing key backup.

Confirm the exact format and behavior in your own version before you rely on it. The key identifiers, the expected layout of the entries and whether a retired key is served through the key server endpoints are version-dependent, so check the current configuration manual for your release and test with a second server. Use a federation tester or a request from a test server to verify that a retired key is still published and that an event signed before rotation still validates. Repeat that check after every upgrade, because the upgrade notes are where changes to key handling are announced.

Back up and rotate the signing key in a planned sequence

This sequence lets you rotate a Synapse signing key without breaking federation or losing the ability to verify past events. Each step ends with a check so the rotation can be stopped or reversed before the old key is retired.

  1. Locate and record the current signing key

    The homeserver administrator finds the signing key file configured in the Synapse setup, usually named in the signing_key_path setting, and reads its key identifier from the file's first line, which has the form of an algorithm and an ID. Record that identifier, the host it runs on and the server_name in the change ticket. Done means the identifier is written down and matches what the running server reports when you check its federation keys endpoint locally. Confirm the exact file location and format against the Synapse configuration manual for your installed version.

  2. Take an encrypted offline backup

    The administrator copies the signing key file to encrypted storage that is kept offline or in a separately controlled vault, with access limited to named people who need it for recovery. Set file permissions so only the Synapse service account and the key custodians can read the backup, and record who holds the decryption material separately from the backup itself. Done means the copy exists, its checksum is recorded in the ticket, and the custodians have confirmed they can open it. Ask your security team to confirm the encryption and access model meets your key management policy.

  3. Test restore on a non-production host

    On a separate host that is not federating publicly, the team restores the backed-up key into a test Synapse configuration and confirms the server starts and reports the same key identifier as production. This proves the backup is usable before anything changes on the live server. Done means the restored key matches the recorded identifier and the test instance starts without key errors. Keep the test host off the public network so it cannot be mistaken for the live homeserver.

  4. Schedule the rotation window with federation peers

    The team agrees a maintenance window and notifies the operators of the remote servers that matter most to your users, since they cache your keys for a period. Prepare the new key with a new identifier and keep the old key file in place. Done means the change calendar, rollback owner and communication are approved, and the new key file is staged on the host but not yet loaded. Confirm the caching behavior of remote servers with the Synapse federation documentation before setting expectations.

  5. Configure old_signing_keys and load the new key

    The administrator sets the signing_key_path to the new key and adds the previous key identifier and its key material under old_signing_keys in the homeserver configuration, so Synapse can still verify events signed under the old key. Validate the configuration file syntax before restarting. Done means the configuration parses cleanly and the old key identifier appears in the list. Check the exact key names and format in the Synapse configuration manual, because a wrong entry here can make past events unverifiable.

  6. Restart and verify federation with a test server

    The administrator restarts Synapse during the agreed window and confirms the server publishes the new key identifier alongside the old one through its federation keys endpoint. Then the team runs a federation check against a controlled test remote server, sending a message from a test account in a shared room and confirming it is delivered and that the remote server accepts events signed by both keys. Done means the test room exchange succeeds in both directions and the logs show no signature errors. If the check fails, restore the previous key file and configuration and stop the rotation.

  7. Monitor and retire the backup under retention policy

    For a period set by your retention policy, the team watches federation error logs and confirms no peer reports signature failures. Keep the old key backup in encrypted storage until the policy allows deletion, then destroy it using your documented process and record the destruction in the change log. Done means the monitoring period closes without signature issues and the backup disposal is recorded with the approver's name. Ask your compliance lead to confirm how long key material must be retained for your sector.

Protecting the key file and its backups

The signing key is the one file that proves your server's events are genuine to every other homeserver. The controls below keep that file readable only by the process that needs it, keep copies out of reach of whoever runs the server day to day, and make any unexpected change visible.

Restrict file permissions

Make the signing key readable only by the account that runs Synapse, and no other local user or group. Check ownership and mode on the key file after every package upgrade, container rebuild or configuration management run, since those steps can reset them. Confirm that the directory holding the key is not world-readable either, because a readable parent can expose a copy made during maintenance. The Synapse process needs the key at startup, so a mode that blocks other accounts rarely affects normal operation.

Encrypt backup copies at rest

Every backup of the signing key should be encrypted before it reaches general backup storage, using a key that is stored separately from the backup itself. Ordinary server backups often have wide read access for operators and restore tooling, so an unencrypted key copy there is effectively a copy on every administrator's laptop. Ask who holds the decryption material, how it is rotated, and whether a restore has been tested with the key file recovered from the encrypted copy.

Separate backup custody from operators

Keep the encrypted key backup under the control of a person or team that does not administer the homeserver day to day. If the same operator can run Synapse, read the key and decrypt the backup, a single compromised account can impersonate your server to federated peers. Record who holds each custody role, and require two people for retrieving the key outside a planned restore or key rotation.

Log every read of the key

Enable audit logging on the host or storage path that holds the signing key so that each read, copy and attribute change is recorded with a user and timestamp. Synapse reads the key when it starts, so a read outside a restart window is a signal worth reviewing. Forward these logs to a store the server operator cannot edit, and test that an alert fires when a non-service account touches the file.

Keep the key out of images and repositories

Do not bake the signing key into a container image, a Helm values file, a Git repository or a CI variable that a wide group can read. Images are copied to registries and caches, and repositories keep history even after a file is deleted. Mount the key from a secret store or a protected volume at runtime, and scan repositories and images for the key's file name and key header before they are published.

Monitor for unexpected key changes

Track a fingerprint of the signing key and alert whenever it changes outside a planned rotation. A new key appearing on disk without a change record can mean a restore from the wrong backup, a rebuild that generated a fresh key, or a tampered host. Compare the active key ID with the expected value during each deployment, and document the rotation procedure so that an alert can be checked against it quickly.

Questions teams ask before changing or protecting their signing key

How much effort does a signing key protection review take?

The effort depends on how many Synapse processes share the key, where the key file lives, and how much of the setup is already documented. A single homeserver with the key on local disk and no existing backup is a small review. A cluster with workers, containers that mount the key from a volume, or several environments that must stay consistent takes longer. Other drivers include how many federation peers depend on the server, whether any old keys were ever retained, and whether a test host with the same Synapse version and database exists. Ask for a written scope that lists the hosts, the key path, the backup location and the change window before agreeing on a timeline or quote.

Can our own team back up and rotate the signing key?

Yes, if your team can work confidently on the Synapse host and in its configuration. Backup is a secure file copy with restricted permissions and a tested restore. Rotation involves generating or placing a new key, moving the previous key into the old_signing_keys setting with its validity period, and restarting Synapse in the right order. The main risks are copying the key to an unprotected location, changing configuration in the wrong order, and restarting one process while others still use the old key. Teams with Linux administration and configuration management experience usually manage the steps with a written runbook. Teams without that experience often bring in a partner for the first rotation and keep the runbook for later.

What does the work need from our side?

The work needs access and decisions from your team in four areas. First, administrative access to the Synapse host, its configuration files, the container or Kubernetes objects that mount the key, and the secrets store if one is used. Second, a test host that runs the same Synapse version, configuration and database layout, so the rotation can be rehearsed before production. Third, a change window agreed with the teams that depend on the homeserver. Fourth, a named contact who can coordinate with administrators of federated servers if the rotation changes how they verify your events. DeployOpen works inside your infrastructure, so the access model, approval steps and evidence handling should be agreed in writing before work starts.

What happens if the homeserver signing key is lost?

Losing the key means the server can no longer sign new events with the identity other servers have on record. Other servers have cached your public key, so events signed with a new key will not verify until they refresh their copy, and some may reject them. Past events signed with the lost key can only be verified again if the public key was preserved somewhere else, which is why the key must be backed up before any change. Confirm how your Synapse version behaves when the key file is missing at startup, because the server may generate a replacement without warning. Treat the recovery as an incident: restore from backup where possible, record the key change, and plan communication with federation peers.

How long must old signing keys stay in the configuration?

Keep an old signing key listed in old_signing_keys for as long as other servers may need to verify events it signed. The length of that period depends on how far back your room history reaches, how often remote servers fetch and cache keys, and any internal retention rules that apply to chat records. Each old key entry records the key and the time it stopped being used, so removing it too early can make older events unverifiable for peers that rely on them. Confirm the exact fields and behavior for your Synapse version in the Synapse configuration manual. Record the retention decision in your runbook so that future administrators do not remove keys without review.

Does rotating the signing key affect end-to-end encrypted messages?

Usually not directly. The homeserver signing key authenticates the server to federation peers. End-to-end encryption uses user device keys and room session keys held by clients, and those are separate from the server signing key. Rotation does not normally change message keys or the key backups users store with their clients. The indirect risk is verification: if other servers cannot verify events signed by your server during the transition, federated encrypted conversations may show delays or errors. Test this on the rehearsal host with at least one encrypted room that spans a federated server. Confirm the behavior with your Synapse version and client versions before the change window.

Should we rotate the signing key on a schedule or only after an incident?

The right trigger depends on your risk policy and how the key has been handled so far. Common drivers for an unscheduled rotation include a suspected exposure of the key file, a compromised administrator account, a host migration that copies the key, or the departure of staff who had access to it. Routine rotation on a schedule adds federation churn and requires the same rehearsal, change window and peer coordination as an incident response, so it should be weighed against that cost. Whichever policy you choose, the controls that matter most are restricted file permissions, a tested backup, a documented old_signing_keys history and a runbook that names who approves a change. Ask any partner to show how their plan covers each of these before work starts.

Where to confirm the exact key behavior for your version

Before you change how your homeserver signing key is stored, backed up or rotated, confirm the exact setting names and defaults in the Synapse configuration manual. Look up the key path setting (signing_key_path) and the field that carries retired keys (old_signing_keys), and record what each one accepts in the version you run. Treat the manual as the authority for syntax and meaning, and compare it with the configuration file on your own server rather than relying on examples copied from older guides. Note any setting that is marked as deprecated or that your version does not recognize, because a misspelled key may fail silently.

The federation documentation explains how other servers find and verify your keys, which is the part of the topic that affects remote servers and not only your own installation. Read it alongside your delegation design, since the host that serves /.well-known responses and the host that answers federation requests determine which server remote peers contact. After any key change, confirm from outside your network that the published keys match what your server now uses, and that the federation listener on port 8448 or your delegated port is reachable as expected. Write down the result so the next person can repeat the check.

Version-specific behavior changes are documented in the Synapse upgrade notes. Read every set of notes between your current release and your target release, not only the newest one, because a key-related change can appear in an earlier entry. The notes also warn that rolling back can be difficult because of database schema changes, so take a verified database backup and copy the current signing key file before any upgrade. Rehearse rotation on a staging copy of the server first, and keep a dated record of which key was active at each point in time.

How DeployOpen scopes and delivers signing key protection

DeployOpen plans and delivers signing key protection for Synapse inside infrastructure you control, from the first key inventory through backup, rotation planning and handover. Work is agreed as a fixed scope with written deliverables, and ongoing support is available as a retainer.

How we scope

  • Inventory each homeserver's signing key file, its location, its owner and the backups that hold a copy today.
  • Confirm the server_name, federation exposure and whether federation_domain_whitelist is in use before changing any key handling.
  • Agree in writing who holds the key backup, where it is stored and who can approve a rotation.

How we build

  • Set file permissions and storage for the signing key so only the Synapse service account and approved backup jobs can read it.
  • Build an encrypted, access-logged backup of the key and test a restore on a separate host before relying on it.
  • Document the rotation procedure, including how old_signing_keys is populated, and test it in a non-production environment first.

How we hand over

  • Deliver a runbook covering key location, backup schedule, restore steps, rotation steps and rollback limits.
  • Provide the test records from restore and rotation drills so your team can repeat them without DeployOpen.
  • Walk your operators through how to confirm that other servers still accept past events after a rotation.

How we support

  • Review key handling again after each Synapse upgrade, since upgrade notes can change how keys and schemas are handled.
  • Run periodic restore tests and keep the runbook current as hosts, backup tools and staff change.
  • Offer continuous testing and upgrade support as a retainer, priced from the written scope rather than a fixed list.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.