The Hashicorp Key Management Plugin is used to implement encryption using keys stored in the Hashicorp Vault KMS. For more information, see Hashicorp Vault and MariaDB, and for how to install Vault, see Install Vault, as well as MySQL/MariaDB Database Secrets Engine.
The current version of this plugin implements the following features:
Since we require support for key versioning, the key-value storage must be configured in Hashicorp Vault as a key-value storage that uses the interface of the second version. For example, you can create it as follows:
~$ vault secrets enable -path /test -version=2 kv
Key names must correspond to their numerical identifiers. Key identifiers itself, their possible values and rules of use are described in more detail in the MariaDB main documentation.
From the point of view of the key-value storage (in terms of Hashicorp Vault), the key is a secret containing one key-value pair with the name "data" and a value representing a binary string containing the key value, for example:
~$ vault kv get /test/1 ====== Metadata ====== Key Value --- ----- created_time 2019-12-14T14:19:19.42432951Z deletion_time n/a destroyed false version 1 ==== Data ==== Key Value --- ----- data 0123456789ABCDEF0123456789ABCDEF
Keys values are strings containing binary data. MariaDB currently uses the AES algorithm with 256-bit keys as the default encryption method. In this case, the keys that will be stored in the Hashicorp Vault should be 32-byte strings. Most likely you will use some utilities for creating and administering keys designed to work with Hashicorp Vault. But in the simplest case, keys can be created from the command line through the vault utility, for example, as follows:
~$ vault kv put /test/1 data="0123456789ABCDEF0123456789ABCDEF"
If you use default encryption (AES), you should ensure that the key length is 32 bytes, otherwise it may fail to use InnoDB as a data storage.
The plugin currently does not unseal Hashicorp Vault on its own, you must do this in advance and on your own.
To use Hashicorp Vault KMS, the plugin must be preloaded and activated on the server. Most of its parameters should not be changed during plugin operation and therefore must be preconfigured as part of the server configuration through configuration file or command line options:
--plugin-load-add=hashicorp_key_management.so --loose-hashicorp-key-management --loose-hashicorp-key-management-vault-url="$VAULT_ADDR/v1/test" --loose-hashicorp-key-management-token="$VAULT_TOKEN"
The plugin supports the following parameters, which must be set in advance and cannot be changed during server operation:
hashicorp-key-management-vault-urlhttps:// for a secure connection) and, according to the API rules for storages of the key-value type in Hashicorp Vault, after the server address, the path must begin with the "/v1/" string (as prefix), for example: https://127.0.0.1:8200/v1/my_secrets. By default, the path is not set, therefore you must replace with the correct path to your secrets. --[loose-]hashicorp-key-management-vault-url="<url>" hashicorp-key-management-token--[loose-]hashicorp-key-management-token="<token>" hashicorp-key-management-vault-ca--[loose-]hashicorp-key-management-vault-ca="<path>" hashicorp-key-management-timeout--[loose-]hashicorp-key-management-timeout=<timeout> hashicorp-key-management-retries----[loose-]hashicorp-key-management-retries=<retries> hashicorp-key-management-caching-enabled--[loose-]hashicorp-key-management-caching-enabled="on"|"off" hashicorp-key-management-use-cache-on-timeout--[loose-]hashicorp-key-management-use-cache-on-timeout="on"|"off" hashicorp-key-management-cache-timeout--[loose-]hashicorp-key-management-cache-timeout=<timeout> hashicorp-key-management-cache-version-timeout--[loose-]hashicorp-key-management-cache-version-timeout=<timeout> hashicorp-key-management-check-kv-version--[loose-]hashicorp-key-management-check-kv-version="on"|"off"
© 2023 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/hashicorp-key-management-plugin/