Server-Side Object Encryption with Hashicorp Vault Root KMS
This procedure assumes a single host machine running the MinIO and KES containers. As part of this procedure, you will:
Deploy a KES container configured to use Vault as the root KMS.
Create a new EK on Vault for use with SSE.
Deploy a MinIO Server container in Single-Node Single-Drive mode configured to use the KES container for supporting SSE.
Configure automatic bucket-default SSE-KMS.
For production orchestrated environments, use the MinIO Kubernetes Operator to deploy a tenant with SSE enabled and configured for use with Hashicorp Vault.
For production baremetal environments, see the MinIO on Linux documentation for tutorials on configuring MinIO with KES and Hashicorp Vault.
Important
Enabling SSE on a MinIO deployment automatically encrypts the backend data for that deployment using the default encryption key.
MinIO requires access to KES and the root KMS to decrypt the backend and start normally. You cannot disable KES later or “undo” the SSE configuration at a later point.
Prerequisites
Deploy or Ensure Access to a Hashicorp Vault Service
This procedure assumes an existing Hashicorp Vault installation accessible from the local host. The Vault Quick Start provides a sufficient foundation for the purposes of this procedure. Defer to the Vault Documentation for guidance on deployment and configuration.
KES Operations Require Unsealed Vault
You must unseal the Vault instance to allow any cryptographic operations, including key creation and retrieval. KES returns an error if the configured Vault service is sealed.
If you restart or otherwise seal the Vault instance, KES cannot perform any cryptographic operations against the Vault. You must unseal the Vault to ensure normal operations.
See the Vault documentation on Seal/Unseal for more information.
MinIO KES supports either the V1 or V2 Vault K/V engines.
MinIO KES requires using AppRole authentication to the Vault server. You must create an AppRole, assign it a policy that the necessary permissions, and retrieve the AppRole ID and Secret for use in configuring KES.
You can use the following steps to enable AppRole authentication and create the necessary policies to support core KES functionality against Vault:
Enable AppRole Authentication
vault auth enable approle
Create a Policy for KES
Create a policy with necessary capabilities for KES to use when accessing Vault. Select the tab corresponding to the KV engine used for storing KES secrets:
Create an access policy
kes-policy.hcl
with a configuration similar to the following:path "kv/*" { capabilities = [ "create", "read", "delete" ] }
Write the policy to Vault using
vault policy write kes-policy kes-policy.hcl
.Create an access policy
kes-policy.hcl
with a configuration similar to the following:path "kv/data/*" { capabilities = [ "create", "read"] } path "kv/metadata/*" { capabilities = [ "list", "delete"] }
Write the policy to Vault using
vault policy write kes-policy kes-policy.hcl
Create an AppRole for KES and assign it the created policy
vault write auth/approle/role/kes-role token_num_uses=0 secret_id_num_uses=0 period=5m vault write auth/approle/role/kes-role policies=kes-policy
Retrieve the AppRole ID and Secret
vault read auth/approle/role/kes-role/role-id vault write -f auth/approle/role/kes-role/secret-id
Install Podman or a Similar Container Management Interface
This procedure assumes you have a working Podman installation configured to run in “Rootfull” mode.
“Rootless” modes may not provide sufficient permissions to run KES with the necessary security settings. See the relevant “rootless” documentation for more information.
(Podman) Deploy MinIO and KES with Server-Side Encryption using Hashicorp Key Vault
Prior to starting these steps, create the following folders:
mkdir -P ~/minio-kes-vault/certs
mkdir -P ~/minio-kes-vault/config
mkdir -P ~/minio-kes-vault/minio
For Windows hosts, substitute the paths with Windows-style paths, e.g. C:\minio-kes-vault\
.
1) Generate TLS Certificates for KES and MinIO
The following commands create two TLS certificates that expire within 30 days of creation:
A TLS certificate for KES to secure communications between it and the Hashicorp Vault service.
A TLS certificate for MinIO to perform mTLS authentication to KES.
Use Caution in Production Environments
DO NOT use the TLS certificates generated as part of this procedure for any long-term development or production environments.
Defer to organization/industry best practices around TLS certificate generation and management. A complete guide to creating valid certificates (e.g. well-formed, current, and trusted) is beyond the scope of this procedure.
# These commands output keys to ~/minio-kes-vault/certs and ~/minio-kes-vault/certs on the host operating system
podman run --rm \
-v ~/minio-kes-vault/certs:/certs \
quay.io/minio/kes:2024-01-11T13-09-29Z identity new kes_server \
--key /certs/kes-server.key \
--cert /certs/kes-server.cert \
kes-server
podman run --rm \
-v ~/minio-kes-vault/certs:/certs \
quay.io/minio/kes:2024-01-11T13-09-29Z identity new minio_server \
--key /certs/minio-kes.key \
--cert /certs/minio-kes.cert \
minio-server
Depending on your Vault configuration, you may need to pass the kes-server.cert
as a trusted Certificate Authority. See the Hashicorp Vault Configuration Docs for more information.
Defer to the client documentation for instructions on trusting a third-party CA.
2) Create the KES and MinIO Configurations
Create the KES Configuration File
Create the configuration file using your preferred text editor. The following example uses
nano
:nano ~/minio-kes-vault/config/kes-config.yaml
KES uses a YAML-formatted configuration file. The following YAML provides the minimum required fields for using Hashicorp Vault as the root KMS. You must modify this YAML to reflect your deployment environment.
address: 0.0.0.0:7373 # Disable the root administrator identity, as we do not need that level of access for # supporting SSE operations. admin: identity: disabled # Specify the TLS keys generated in the previous step here # For production environments, use keys signed by a known and trusted Certificate Authority (CA). tls: key: /certs/kes-server.key cert: /certs/kes-server.cert # Specify the path to CAs used by KES for validating client certificates # This can alternatively be a single CA # KES uses these CAs in addition to the system trust store for validating client certificates. ca: /certs/CAs/ # Sets access policies for KES # The `minio` policy grants access to the listed APIs. policy: minio: allow: - /v1/key/create/* # You can replace these wildcard '*' with a string prefix to restrict key names - /v1/key/generate/* # e.g. '/minio-' - /v1/key/decrypt/* - /v1/key/bulk/decrypt - /v1/key/list/* - /v1/status - /v1/metrics - /v1/log/audit - /v1/log/error identities: - MINIO_API_KEY_HASH # Replace with the hash output returned from kes identity new # Specify the connection information for the Vault server. # The endpoint should be resolvable from the host. # This example assumes that Vault is configured with an AppRole ID and # Secret for use with KES. keystore: vault: endpoint: https://HOSTNAME:8200 engine: "/path/to/engine" # Replace with the path to the K/V Engine version: "v1|v2" # Specify v1 or v2 depending on the version of the K/V Engine approle: id: "VAULTAPPID" # Hashicorp Vault AppRole ID secret: "VAULTAPPSECRET" # Hashicorp Vault AppRole Secret ID retry: 15s status: ping: 10s # Required if Vault uses certificates signed by an unknown CA, # e.g. self-signed or internal (non-globally trusted). # Replace this value with the full path to the Vault CA certificate. tls: ca: vault-tls-CA.cert
Set
MINIO_IDENTITY_HASH
to the identity hash of the MinIO mTLS certificate.The following command computes the necessary hash:
podman run --rm \ -v ~/minio-kes-vault/certs/certs:/certs \ kes:2024-01-11T13-09-29Z tool identity of /certs/minio-kes.cert
Replace the
vault.endpoint
with the hostname of the Vault server(s).Replace the
VAULTAPPID
andVAULTAPPSECRET
with the appropriate Vault AppRole credentials.
Create the MinIO Environment File
Create the environment file using your preferred text editor. The following example uses
nano
:nano ~/minio-kes-vault/config/minio
This command assumes the
minio-kes.cert
,minio-kes.key
, andkes-server.cert
certificates are accessible at the specified location:MINIO_ROOT_USER=myminioadmin MINIO_ROOT_PASSWORD=minio-secret-key-change-me MINIO_VOLUMES="/mnt/data" # KES Configurations MINIO_KMS_KES_ENDPOINT=https://127.0.0.1:7373 MINIO_KMS_KES_CERT_FILE=/certs/minio-kes.cert MINIO_KMS_KES_KEY_FILE=/certs/minio-kes.key MINIO_KMS_KES_CAPATH=/certs/server.cert MINIO_KMS_KES_KEY_NAME=minio-backend-default-key MINIO_KMS_KES_ENCLAVE=<name>
MinIO uses the
MINIO_KMS_KES_KEY_NAME
key for the following cryptographic operations:Encrypting the MinIO backend (IAM, configuration, etc.)
Encrypting objects using SSE-KMS if the request does not include a specific EK.
Encrypting objects using SSE-S3.
MinIO uses the
MINIO_KMS_KES_ENCLAVE
key to define the name of the KES enclave to use.Replace
<name>
with the name of the enclave to use.If not defined, MinIO does not send any enclave information. This may result in using the default enclave for stateful KES servers.
A KES enclave isolates its associated keys from other enclaves on a stateful KES server.
The
minio-kes
certificates enable for mTLS between the MinIO deployment and the KES server only. They do not otherwise enable TLS for other client connections to MinIO.KES automatically creates this key if it does not already exist on the root KMS.
3) Create Pod and Containers
The commands in this section create the following resources:
A Podman Pod to facilitate container communications
A Container for the KES Server configured to use Hashicorp Vault as the Root KMS.
A Container for a MinIO Server running in Single-Node Single-Drive Mode.
sudo podman pod create \
-p 9000:9000 -p 9001:9001 -p 7373:7373 \
-v ~/minio-kes-vault/certs:/certs \
-v ~/minio-kes-vault/minio:/mnt/minio \
-v ~/minio-kes-vault/config:/etc/default/ \
-n minio-kes-vault
sudo podman run -dt \
--cap-add IPC_LOCK \
--name kes-server \
--pod "minio-kes-vault" \
-e KES_SERVER=https://127.0.0.1:7373 \
-e KES_CLIENT_KEY=/certs/kes-server.key \
-e KES_CLIENT_CERT=/certs/kes-server.cert \
quay.io/minio/kes:2024-01-11T13-09-29Z server \
--auth \
--config=/etc/default/kes-config.yaml \
sudo podman run -dt \
--name minio-server \
--pod "minio-kes-vault" \
-e "MINIO_CONFIG_ENV_FILE=/etc/default/minio" \
quay.io/minio/minio:RELEASE.2024-02-17T01-15-57Z server \
--console-address ":9001"
You can verify the status of the containers using the following commands:
# Should show three pods - one for the Pod, one for KES, and one for MinIO
sudo podman container ls
If all pods are operational, you can connect to the MinIO deployment by opening your browser to http://127.0.0.1:9000 and logging in with the root credentials specified in the MinIO environment file.
4) Generate a New Encryption Key
Unseal Vault Before Creating Key
You must unseal the backing Vault instance before creating new encryption keys. See the Vault documentation on Seal/Unseal for more information.
MinIO requires that the EK exist on the root KMS before performing
SSE operations using that key. Use kes key create
or
mc admin kms key create
to create a new EK for use with SSE.
The following command uses the kes key create
command to add a new
External Key (EK) stored on the root KMS server for use with encrypting
the MinIO backend.
sudo podman run --rm \
-v ~/minio-kes-vault/certs:/certs \
-e KES_SERVER=https://127.0.0.1:7373 \
-e KES_CLIENT_KEY=/certs/minio-kes.key \
-e KES_CLIENT_CERT=/certs/minio-kes.cert \
kes:2024-01-11T13-09-29Z key create -k my-new-encryption-key
You can specify any key name as appropriate for your use case, such as a bucket-specific key minio-mydata-key
.
5) Enable SSE-KMS for a Bucket
You can use either the MinIO Console or the MinIO mc
CLI to enable bucket-default SSE-KMS with the generated key:
Open the MinIO Console by navigating to http://127.0.0.1:9001 in your preferred browser and logging in with the root credentials specified to the MinIO container.
Once logged in, create a new Bucket and name it to your preference. Select the Gear icon to open the management view.
Select the pencil icon next to the Encryption field to open the modal for configuring a bucket default SSE scheme.
Select SSE-KMS, then enter the name of the key created in the previous step.
Once you save your changes, try to upload a file to the bucket. When viewing that file in the object browser, note that in the sidebar the metadata includes the SSE encryption scheme and information on the key used to encrypt that object. This indicates the successful encrypted state of the object.
The following commands:
Create a new alias for the MinIO deployment
Create a new bucket for storing encrypted data
Enable SSE-KMS encryption on that bucket
mc alias set local http://127.0.0.1:9000 ROOTUSER ROOTPASSWORD
mc mb local/encryptedbucket
mc encrypt set SSE-KMS encrypted-bucket-key ALIAS/encryptedbucket
Write a file to the bucket using mc cp
or any S3-compatible SDK with a PutObject
function.
You can then run mc stat
on the file to confirm the associated encryption metadata.
Configuration Reference for Hashicorp Vault
The following section describes each of the Key Encryption Service (KES) configuration settings for using Hashicorp Vault as the root Key Management Service (KMS) for SSE.
Important
Starting with https://github.com/minio/minio/releases/tag/RELEASE.2023-02-17T17-52-43Z, MinIO requires expanded KES permissions for functionality. The example configuration in this section contains all required permissions.
The following YAML describes the minimum required fields for configuring Hashicorp Vault as an external KMS for supporting SSE.
Fields with ${<STRING>}
use the environment variable matching the <STRING>
value.
You can use this functionality to set credentials without writing them to the configuration file.
The YAML assumes a minimal set of permissions for the MinIO deployment accessing KES.
As an alternative, you can omit the policy.minio-server
section and instead set the ${MINIO_IDENTITY}
hash as the ${ROOT_IDENTITY}
.
address: 0.0.0.0:7373
admin:
identity: ${ROOT_IDENTITY}
tls:
key: kes-server.key
cert: kes-server.cert
policy:
minio-server:
allow:
- /v1/key/create/*
- /v1/key/generate/*
- /v1/key/decrypt/*
- /v1/key/bulk/decrypt
- /v1/key/list/*
- /v1/status
- /v1/metrics
- /v1/log/audit
- /v1/log/error
identities:
- ${MINIO_IDENTITY}
keys:
- name: "minio-encryption-key-alpha"
- name: "minio-encryption-key-baker"
- name: "minio-encryption-key-charlie"
keystore:
vault:
endpoint: https://vault.example.net:8200
engine: "kv"
version: "v1"
namespace: "minio"
prefix: "keys"
approle:
id: ${KES_APPROLE_ID}
secret: ${KES_APPROLE_SECRET}
retry: 15s
status:
ping: 10s
tls:
key: "kes-mtls.key"
cert: "kes-mtls.cert"
ca: vault-tls.cert
Key |
Description |
---|---|
|
The network address and port the KES server listens to on startup.
Defaults to port |
|
The identity for the KES superuser ( Specify |
|
The TLS private key and certificate used by KES for establishing TLS-secured communications.
Specify the full path for both the private |
|
Specify one or more policies to control access to the KES server. MinIO SSE requires access to the following KES cryptographic APIs:
Specifying additional keys does not expand MinIO SSE functionality and may violate security best practices around providing unnecessary client access to cryptographic key operations. You can restrict the range of key names MinIO can create as part of performing
SSE by specifying a prefix before the KES uses mTLS to authorize connecting clients by comparing the
hash of the TLS certificate against the |
|
Specify an array of keys which must exist on the root KMS for KES to successfully start. KES attempts to create the keys if they do not exist and exits with an error if it fails to create any key. KES does not accept any client requests until it completes validation of all specified keys. |
|
The configuration for the Hashicorp Vault keystore. The following fields are required:
|