License Configuration
MassTransit v9 (and beyond) requires a license to use, which gives you a license key file. Once you receive your license key, it will look similar to the license shown below (with your own values):
-----BEGIN LICENSE KEY-----c1SDNOXHUwMDJCTUFkSVRqTExWSzMwc0xiUkxMM0JDa3ZhWUpXWFNUbXJ3N1x1MDAyQmRFRjR0WnZiblJ2WW1Wc0lpd2laVzFoYVd3aU9pSnpkRtWVc0dVpHRmxkSGQ1YkdWeVFIWnZiblJ2WW1WT2lJeU1ESMVEV5TFRBNVZEQXdPakF3T2pBd1dpSXNJbVY0Y0dseVpYTWlPaUl5TURJM0xUQXhMeyJ2ZXJzaW9uIjojEiLCJraW5kIjoiTGljZW5zZSIsIm1ldGEiOnsic2lnbmF0dXJlLWFsZ29yc0xtTnZiU0o5TENKamRYTjMjFsY2lJNmV5SnBaQ0k2SW1OMWMxOVVXbHBIYzFCUVlrOW1jRzR4T0NJc0ltNWhiV1VpT2lKQ1lXNJRlp2Ym5SdlltVnNJbjBzSW5CeWIyUjFZM1J6SWpwN0ltMWhjOXVJam9pVFdGemMxUnlZV6YVhRZ1RHbGpaVzV6WlNJc0ltVjRjR2x5WlhNaU9pSXlNREkyTFRFeUxUQTVWREF3T2pBd09qdXaUlzSW1abFlYUjFjbVZ6SWpwdWRXeHNmWDBzSW1OeVpXRjBaV1FpVEE0VkRBd09qQXdPakF3lKOSIsInNpZ25hdHVyZSI6IkFYMVRJNWE2c1dMZXVoNi9rLzcxNk8vaXRobSI6IkVDRHNhIn0sImRhdGEiJleUpqYjI1MFlXTjBJanA3SW01aGJXVWlPaUpDWVc1cklGM04wY21GdWMybDBJanA3SW01aGJXVWlPpOWVhOelZISmhibk5wZENJc0ltUmxjMk55YVhCMGFXVWJMMTF1R0libXd2YjlWR2ZhUTlkZ1FERExseDQUdrMVBvdmhaRkN2ajdWbDlQVFNiVkFFdUE3-----END LICENSE KEY-----Configure the license key
Section titled “Configure the license key”The license key can be configured in several ways, depending on your environment.
Environment Variable (Key)
Section titled “Environment Variable (Key)”Environment variables are a great way to store secrets and provide them to your application. They are easy to specify when using Docker or Kubernetes, both of which offer secure secret storage mechanisms.
Your license key can be set in an environment variable named MT_LICENSE and loaded automatically.
export MT_LICENSE="..."Environment Variable (File)
Section titled “Environment Variable (File)”You can store your license in a file and specify the file location using the MT_LICENSE_PATH environment variable. MassTransit will attempt to open and use
the license when the bus is configured.
export MT_LICENSE_PATH="/app/license.txt"License Key
Section titled “License Key”You can specify the license directly by calling SetLicense on the bus configurator. This allows you to store the key however you want and provide it to the
bus configuration.
services.AddMassTransit(x =>{ string licenseKey = ""; // load the key here
x.UsingRabbitMq((context, cfg) => { cfg.SetLicense(licenseKey);
cfg.ConfigureEndpoints(context); });});License File
Section titled “License File”You can store your license in a file that is deployed with your application and specify the file location by calling SetLicenseLocation on the bus
configurator.
services.AddMassTransit(x =>{ x.UsingRabbitMq((context, cfg) => { cfg.SetLicenseLocation("./license.txt");
cfg.ConfigureEndpoints(context); });});License Key Management
Section titled “License Key Management”The license key must be accessible at runtime on any machine or container that executes MassTransit code. This includes:
- Developer laptops (local builds and tests)
- CI/CD agents
- Test and staging environments
- Production deployments (VMs, containers, Kubernetes, etc.)
MassTransit does not use a central license server or activation service. MassTransit validates the license key locally within the running process to ensure reliability, offline operation, and predictable startup behavior.
License Key Distribution
Section titled “License Key Distribution”Your license key should be treated like any other secret. It should not be committed to source control or baked into container images.
Recommended key distribution approaches include:
- Environment variables
- Secret stores (Azure Key Vault, AWS Secrets Manager, HashiCorp Vault, etc.)
- Kubernetes secrets
- CI/CD secret injection (GitHub Actions, etc.)
At application startup, your application reads the license key from configuration just like a connection string or API token. This allows you to apply the license key within an environment without impact to the existing code.
Local Development Guidance
Section titled “Local Development Guidance”For local development, we recommend one of the following approaches:
- Store the license key in a local environment variable or user-specific secret store
- Use a
.envfile that is explicitly excluded from version control - Configure your IDE or local tooling to inject the license at runtime
This ensures developers can run and test MassTransit locally without exposing the license in shared repositories.
CI/CD Pipelines
Section titled “CI/CD Pipelines”CI/CD systems should inject the license key as a secret, either at the organization or repository level.
For containerized builds:
- Inject the license at runtime, not at container image build time
- Avoid embedding the license in Dockerfiles or base images
Reducing Distribution Risk
Section titled “Reducing Distribution Risk”Because MassTransit executes wherever your application runs, the license does need to be broadly available but it does not need to be broadly visible.
To minimize risk:
- Restrict access to secrets at the infrastructure level
- Avoid copying license values into documentation, scripts, or example configs
- Limit who can read secret values in CI/CD and production systems