Open Source (Self-hosted)
Deploying the DIDComm Mediator locally enables you to explore and understand how message handling and encryption work under the hood. It allows you to customise the configuration depending on your requirements.
To deploy the DIDComm Mediator from the open-sourced version, follow the steps below:
1. Prerequisites
Before you begin, install the following applications.
Install Rust (1.85.0 2024 Edition) on your machine if you haven’t installed it yet using this guide.
Install Docker on your machine if you haven’t installed it yet using this guide. We will need this to run Redis instance for the mediator to store messages temporarily and mediator configurations.
2. Clone the Mediator Repository
- Clone the GitHub repo on your local.
git clone git@github.com:affinidi/affinidi-tdk-rs.git- Navigate to the
crates/affinidi-messagingfolder.
cd affinidi-tdk-rs/crates/affinidi-messaging3. Set up the Mediator Instance
- Run the Redis Docker container using the command below from your terminal:
docker run --name=redis-local --publish=6380:6380 --hostname=redis --restart=on-failure --detach redis:latestThe latest supported version of Redis is version 8.0.
- Run
setup_environmentto configure the mediator with all the required information to run locally.
cargo run --bin setup_environment
Output from setup_environment
Select Local Mediator Configuration and follow the on-screen instructions. Upon successful setup, it will generate the following information:
- Mediator DID and secrets.
- Administration DID and secrets.
- SSL Certificates for local development/testing.
- Optionally, different users with their DIDs for testing.
Important Note
To the question “Use existing Mediator DID?” during setup, answer “no”. This will generate new DID.- After completing the setup, run the following command to navigate to the
affinidi-messaging-mediatordirectory and start the mediator:
cd affinidi-messaging-mediator && cargo run- To verify that the mediator is running, open
http://localhost:7037/mediator/v1/.well-known/did.jsonin your web browser. This page should display your local mediator’s DID document.
4. Test the Mediator Connection
The repository provides examples that you can run to test whether the setup was successful. To do this, follow the steps below:
- Open another terminal tab and go to the
crates/affinidi-messagingfolder.
cd affinidi-tdk-rs/crates/affinidi-messaging- From the terminal, run the following example.
cargo run --example mediator_pingThe above example will execute a code that authenticates to the mediator and send a ping message. If successful, it sends a pong message back.
Enable Logging
To enable logging to see more information when running the example and to learn more about how it works, set the following environment variables from your terminal.
export RUST_LOG=none,affinidi_messaging_helpers=debug,affinidi_messaging_sdk=infoWhat’s Next
Glad to hear it! Please tell us how we can improve more.
Sorry to hear that. Please tell us how we can improve.
Thank you for sharing your feedback so we can improve your experience.