I have Kumo and Vault setup in Docker in the same network and they’re both working successfully.
I’ve followed the instructions in the documentation to provide the necessary environmental variables, but when trying to retrieve secrets from the Vault an error is thrown:
kumod::smtp_server: Error in SmtpServer: Vault { vault_address: None, vault_token: None, vault_mount: "secret", vault_path: "dkim/..." }: kv2::read vault_mount=secret, vault_path= Vault { vault_address: None, vault_token: None, vault_mount: "secret", vault_path: "dkim/..." }: The Vault server returned an error (status code 404)
The troubleshooting and debug output I’ve put in place leads me to believe it may not be a configuration issue, but how the environment variables are being passed into the Vault client.
I’m using the Docker container provided by KumoMTA ghcr.io/kumocorp/kumomta-dev:latest and have the service running locally on macOS.
I can connect to the Vault using the CLI and web UI, but despite setting the vault_addr and vault_token variables everywhere I can think of, KumoMTA shows both variables as being empty.
I tried looking through the KumoMTA source code in GitHub for additional examples and any potential integration test cases, but wasn’t able to find anything helpful in this regard.
Based on my testing, it appears there’s a bug in the DKIM Policy Extras code that does not reference the Vault environment variables: VAULT_ARR and VAULT_TOKEN.
Connections to the Vault seem to work elsewhere, but have not been tested extensively.
[base]
# If these are present, we'll use hashicorp vault instead of reading from disk
vault_mount = "secret"
vault_path_prefix = "dkim/"
you need at least a [domain] stanza in there to activate signing.
Note that if you do not explicitly set the filename in the domain stanza, the automatically derived vault_path that is set into the signing object will be %s/%s/%s.key, that is the prefix (default: dkim), the domain and the selector, with .key appended. In your straight lua code example, it appears as though you don’t have a .key suffix, so perhaps you need to set the filename in the toml explicitly to exclude that.
When using the above configuration, the Docker logs shown an error:
kumo | 2025-02-13T21:15:48.013512Z ERROR smtpsrv-4 run{socket=PollEvented { io: Some(TcpStream { addr: 172.18.0.2:25, peer: 192.168.65.1:57193, fd: 43 }) }}: kumod::smtp_server: Error in SmtpServer: Vault { vault_address: None, vault_token: None, vault_mount: "secret", vault_path: "dkim/example.test/default.key" }: kv2::read vault_mount=secret, vault_path=dkim/example.test/default.key Vault { vault_address: None, vault_token: None, vault_mount: "secret", vault_path: "dkim/example.test/default.key" }: The Vault server returned an error (status code 404)
kumo | stack traceback:
kumo | [C]: in local 'poll'
kumo | [string "?"]:4: in main chunk
kumo | (...tail calls...)
kumo | /opt/kumomta/share/policy-extras/dkim_sign.lua:283: in upvalue 'do_dkim_sign'
kumo | /opt/kumomta/share/policy-extras/dkim_sign.lua:356: in upvalue 'dkim_signer'
kumo | [string "/opt/kumomta/etc/policy/init.lua"]:59: in function <[string "/opt/kumomta/etc/policy/init.lua"]:56>
A few things from the above error log catch my eye:
Empty values for the vault_address and vault_token variables
Invalid path to the Vault secret (e.g. dkim/example.test/default.key)
It would appear the derived path to the Vault secret is appending the domain selector private key filename (e.g. dkim/example.test/default.key), rather than the secret path Vault expects (e.g. dkim/example.test).
Using the Vault CLI from a Terminal, I’m able to verify the correct path and data returned:
$ vault kv get -mount="secret" "dkim/example.test"