Open source (self-hosted)

Affinidi provides an open-source DIDComm Mediator implementation based on the DIDComm v2.1 protocol.

Deploy and run the DIDComm Mediator on your own infrastructure to manage message routing and customise configuration based on your requirements. As the operator of a self-hosted mediator, you hold its admin DID, so you can manage accounts and DID-level ACLs yourself.

The mediator’s source is the affinidi-messaging-mediator repository. This guide uses release v0.48.0. Check the repository’s releases for a newer one, and build from a release tag rather than main, which carries unreleased changes.

1. Prerequisites

  1. Install Rust 1.95.0 or later.

  2. Choose where the mediator stores messages:

    • Redis: needed for a cluster of mediators. Use Redis 7.1 or later, below 9.0, which the mediator checks at startup. Docker is the simplest way to run it locally.
    • Fjall: an embedded store for a single mediator, with no separate service to run.

2. Get the source

git clone --branch v0.48.0 https://github.com/affinidi/affinidi-messaging-mediator.git
cd affinidi-messaging-mediator

Run the remaining commands from this folder.

3. Set up the mediator instance

  1. If you chose Redis, start it:

    docker run --name=redis-local --publish=6379:6379 --hostname=redis --restart=on-failure --detach redis:8
  2. Run the setup wizard, which generates the configuration, keys, and secrets in one step:

    cargo run --locked --bin mediator-setup

    The wizard asks for:

    • Deployment type: local development, headless server, or container.
    • Protocol: DIDComm v2 only, or DIDComm v2 and the Trust Spanning Protocol (TSP).
    • DID: did:peer, did:webvh, or a DID managed by a Verifiable Trust Agent (VTA).
    • Key storage: where the mediator keeps its secrets, such as a local file, the OS keyring, or a cloud secrets manager.
    • SSL/TLS: none (use a proxy), existing certificates, or self-signed.
    • Database: a Redis URL, or a Fjall data directory.
    • Admin account: generate a did:key, paste an existing one, or skip.

    For a local test, choose local development and did:peer.

  3. Save what the wizard produces:

    • conf/mediator.toml: the configuration. It holds no secrets.
    • conf/keys/: SSL certificates, in self-signed mode only.
    • The admin DID and its private key, shown on screen when the wizard generates the admin account. Store them in your secrets manager, because they control the mediator.
    • conf/admin-monitor.json: the administrator profile for the mediator console, written only when the wizard generates the admin account. It contains the admin DID’s private key, so protect it as you protect the key, and keep it only on machines where you run the console.

    The mediator’s own secrets go to the key storage you chose.

  4. Build and start the mediator with the commands the wizard prints when it finishes. They depend on the options you chose. With DIDComm v2 and TSP, Redis, and key storage in a local file, they are:

    cargo build --release --locked -p affinidi-messaging-mediator
    cargo run --release --locked -p affinidi-messaging-mediator -- -c conf/mediator.toml

    For any other protocol, database, or key storage, use the wizard’s commands instead. They add --no-default-features --features …, so the mediator is built with what you chose.

To set up a server or container without prompts, for example in a CI/CD pipeline, pass --non-interactive and the options as flags. See Non-interactive setup in the mediator’s README.

4. Confirm the mediator is running

Open http://localhost:7037/mediator/v1/.well-known/did in your browser, or https:// if you chose self-signed certificates. The page shows your mediator’s DID document.

5. Manage the mediator

The mediator console shows the mediator’s health, every account’s queues, ACLs and queue limits, the audit log, and live traffic. Connect it with the administrator profile the wizard wrote when it generated the admin account:

cargo run --release -p affinidi-messaging-mediator-tui -- --profile conf/admin-monitor.json

To send test messages through your mediator from an application, see Test mediator connection.

What’s next

  Configure the mediator’s operating mode

  Explore Meeting Place, an implementation of Affinidi Messaging

  Integrate Affinidi Messaging into your applications