Table of Contents
MinIO Server-Side Encryption (SSE) protects objects as part of write operations, allowing clients to take advantage of server processing power to secure objects at the storage layer (encryption-at-rest). SSE also provides key functionality to regulatory and compliance requirements around secure locking and erasure.
MinIO SSE uses Key Encryption Service (KES) and an external root Key Management Service (KMS) for performing secured cryptographic operations at scale. The root KMS provides stateful and secured storage of External Keys (EK) while KES is stateless and derives additional cryptographic keys from the root-managed EK.
This procedure does the following:
Configure KES to use Google Cloud Platform Secret Manager as the root KMS.
Configure MinIO to use the KES instance for supporting SSE.
This procedure assumes familiarity with GCP Secret Manager. The Secret Manager Quickstart provides a sufficient foundation for the purposes of this procedure.
MinIO specifically requires the following GCP settings or configurations:
Enable Secret Manager in the project.
Create a new GCP Service Account for supporting KES. Ensure the user has a role with at minimum the following permissions:
secretmanager.secrets.create
secretmanager.secrets.delete
secretmanager.secrets.get
The Secret manager Admin
role meets the minimum required permissions.
GCP should return a set of credentials associated to the new service account, including private keys. Copy these credentials to a safe and secure location for use with this procedure.
MinIO Key Encryption Service (KES) relies on mutual TLS (mTLS) for authentication and authorization. Enabling SSE therefore requires that the MinIO server, KES, and the root KMS enforce TLS.
The instructions on this page include creation of TLS certificates for supporting mTLS between MinIO and the KES instance. These certificates are appropriate for early development and evaluation environments only.
For instructions on enabling TLS on the MinIO server, see Network Encryption (TLS).
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.
The procedures on this page use the Podman daemonless container engine for running OCI containers. Podman is a drop-in replacement for Docker.
This procedure assues running Podman in “rootless”. Defer to the Podman documentation for installing and configuring Podman to run in rootless mode.
The following steps deploy Key Encryption Service (KES) configured to use an existing AWS KMS and Secrets Manager deployment as the root KMS for supporting SSE. These steps assume the AWS components meet the prerequisites.
Prior to starting these steps, create the following folders:
mkdir -P ~/kes/certs ~/kes/config
You can download the KES binary for running in baremetal environments, or use the KES container image for running in an orchestrated environment:
Download the latest stable release (0.16.1) of KES from github.com/minio/kes.
Select the binary appropriate for the host OS architecture. For example,
hosts running X86-64 (Intel/AMD64) should download the kes-linux-amd64
package.
The following example code downloads the latest Linux AMD64-compatible
binary and moves it to the system PATH
:
wget https://github.com/minio/kes/releases/download/v0.16.1/kes-linux-amd64 -O /tmp/kes && \
chmod +x /tmp/kes && \
sudo mv /tmp/kes /usr/local/bin
kes --version
The following command uses Podman to download the latest stable KES (0.16.1) as a container image:
podman pull quay.io/minio/kes/v0.16.1
You can validate the container downloaded correctly by running the following command:
podman run kes --version
The output should reflect 0.16.1.
This step creates a self-signed TLS certificate for use with KES in evaluation or early development environments. The certificate expires within 30 days of creation.
For production environments, use certificates signed by a trusted Certificate Authority (CA). DO NOT use certificates generated using these instructions in production environments.
The following command creates the self-signed private and public key files
using the kes tool identity new
command:
kes tool identity new --server \
--key ~/kes/certs/server.key \
--cert ~/kes/certs/server.cert \
--ip "127.0.0.1" \
--dns localhost
The following command creates the self-signed private and public key files
using the kes tool identity new
command. podman run --rm
automatically removes the container when the command exists
podman run --rm -v ~/kes/certs:/data/certs \
kes tool identity new --server \
--key /data/certs/server.key \
--cert /data/certs/server.cert \
--ip "127.0.0.1" \
--dns localhost
This command outputs the keys to the ~/kes/certs
directory on the host
operating system.
KES uses mTLS for authorizing a connecting client to perform a requested cryptographic operation. This step creates a new TLS identity for the MinIO deployment to use in performing secure cryptographic operations on KES. The certificate expires within 30 days of creation.
For production environments, use certificates signed by a trusted Certificate Authority (CA). DO NOT use certificates generated using these instructions in production environments.
The following command creates the self-signed private and public key files
using the kes tool identity new
command:
kes tool identity new --server \
--key ~/kes/certs/minio-kes.key \
--cert ~/kes/certs/minio-kes.cert \
--ip "127.0.0.1" \
--dns localhost
The command outputs the keys to the ~/kes/certs
directory.
Use the kes tool identity of
command to compute the identity hash for
the certificate. This hash is required for configuring access to the KES
server in a later step:
kes tool identify of ~/kes/certs/minio-kes.cert
The following command creates the self-signed private and public key files
using the kes tool identity new
command. podman run --rm
automatically removes the container when the command exists
podman run --rm -v ~/kes/certs:/data/certs \
kes tool identity new --key /data/certs/minio-kes.key \
--cert /data/certs/minio-kes.cert
This command outputs the keys to the ~/kes/certs
directory on the host
operating system.
Use the kes tool identity of
command to compute the identity hash for
the certificate. This hash is required for configuring access to the KES
server in a later step:
sudo podman run --rm --v ~/kes/certs:/data/certs \
kes tool identity of /data/certs/minio-kes.cert
KES uses a YAML-formatted configuration file. The following example YAML specifies the minimum required fields for enabling SSE using AWS Secrets Manager:
address: 0.0.0.0:7373
# Disable the root identity, as we do not need that level of access for
# supporting SSE operations.
root: 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: /data/certs/server.key
cert: /data/certs/server.cert
# Create a policy named 'minio' that grants access to the
# /create, /generate, and /decrypt KES APIs for any key name
# KES uses mTLS to grant access to this policy, where only the client
# whose TLS certificate hash matches one of the "identities" can
# use this policy. Specify the hash of the MinIO server TLS certificate
# hash here.
policy:
minio:
allow:
- /v1/key/create/*
- /v1/key/generate/*
- /v1/key/decrypt/*
identities:
- ${MINIO_IDENTITY_HASH} # Replace with the output of 'kes tool identity of minio-kes.cert'
# Specify the connection information for the Secrets Manager endpoint.
# The endpoint should be resolvable from the host.
# This example assumes that the associated GCP account has the necessary
# access key and secret key
keystore:
gcp:
secretmanager:
project_id: "${GCPPROJECTID}" # The GCP Project to use
credentials:
client_email: "${GCPCLIENTEMAIL}" # The client email for your GCP Credentials
client_id: "${GCPCLIENTID}" # The Client ID for your GCP Credentials
private_key_id: "${GCPPRIVATEKEYID}" # the private key ID for your GCP credentials
private_key: "${GCPPRIVATEKEY}" # The content of your GCP Private Key
Save the configuration file as ~/kes/config/kes-config.yaml
. Any field with
value ${VARIABLE}
uses the environment variable with matching name as the
value. You can use this functionality to set credentials without writing them to
the configuration file.
Set MINIO_IDENTITY_HASH
to the output of
kes tool identity of minio-kes.cert
.
Set GCPPROJECTID
to the GCP project for the Secrets Manager instance
KES should use.
Set GCPCLIENTEMAIL
, GCPCLIENTID
, GCPPRIVATEKEYID
, and
GCPPRIVATEKEY
to the credentials associated to the
GCP Service Account
KES should use when accessing the Secrets Manager service.
The first command allows KES to use the mlock system call without
running as root. mlock
ensures the OS does not write in-memory data to
disk (swap memory) and mitigates the risk of cryptographic operations
being written to unsecured disk at any time.
The second command starts the KES server in the foreground using the
configuration file created in the last step. The --auth=off
disables
strict validation of client TLS certificates and is required if either the
MinIO client or the root KMS server uses self-signed certificates.
sudo setcap cap_ipc_lock=+ep $(readlink -f $(which kes))
kes server --mlock \
--config=~/kes/config/server-config.yaml \
--auth=off
KES listens on port 7373
by default. You can monitor the server
logs from the terminal session. If you run KES without tying it to
the current shell session (e.g. with nohup
), use that methods
associated logging system (e.g. nohup.txt
).
The following command starts the KES server using the configuration file
created in the last step. The command includes the necessary extensions
that allow KES to use the mlock system call without
running as root. mlock
ensures the OS does not write in-memory data to
disk (swap memory) and mitigates the risk of cryptographic operations
being written to unsecured disk at any time.
podman run --rm -idt --cap-add=IPC_LOCK \
--name kes-server \
-v ~/kes/certs:/data/certs \
-v ~/kes/config:/data/config \
-p 7373:7373 \
kes server --mlock \
--config=/data/config/server-config.yaml \
--auth=off
The container starts using the specified configuration file and begins
listening for client connections at por 7373
. The server attempts to
connect to the root KMS deployment specified in the server configuration
file.
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 create a new
External Key (EK) stored on the root KMS server for use with encrypting
the MinIO backend.
export KES_SERVER=https://127.0.0.1:7373
export KES_CLIENT_KEY=~/kes/minio-kes.key
export KES_CLIENT_CERT=~/kes/minio-kes.cert
kes key create -k minio-backend-default-key
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 create a new
External Key (EK) stored on the root KMS server for use with encrypting
the MinIO backend.
sudo podman exec -it kes-server /bin/bash
[root@ID /]# /kes key create -k \
-e KES_SERVER=https://127.0.0.1:7373 \
-e KES_CLIENT_KEY=/data/minio-kes.key \
-e KES_CLIENT_CERT=/data/minio-kes.cert \
minio-backend-default-key
Set the following environment variables to configure MinIO to connect to the
KES server. Set these variables on all hosts running MinIO servers in the
deployment. This command assumes the minio-kes.cert
, minio-kes.key
, and
server.cert
certificates are accessible at the specified location:
export MINIO_KMS_KES_ENDPOINT=https://HOSTNAME:7373
export MINIO_KMS_KES_CERT_FILE=~/minio-kes.cert
export MINIO_KMS_KES_KEY_FILE=~/minio-kes.key
export MINIO_KMS_KES_CAPATH=~/server.cert
export MINIO_KMS_KES_KEY_NAME=minio-backend-default-key
minio server [ARGUMENTS]
Replace HOSTNAME
with the IP address or the hostname for the host machine
running the KES server or pod started in the previous step.
Replace the minio server [ARGUMENTS]
to match the command used to
start the MinIO server on that host.
Add all other environment variables as required by the deployment.
MinIO uses the MINIO_KMS_KES_KEY_NAME
key for the following
cryptographic operations:
The following command enables SSE-KMS on all objects written to the specified bucket:
mc mb ALIAS/encryptedbucket
mc encrypt set SSE-KMS encrypted-bucket-key ALIAS/encryptedbucket
Replace ALIAS
with the alias
of the MinIO
deployment configured in the previous step.
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.
The following command enables SSE-S3 on all objects written to the
specified bucket. MinIO uses the MINIO_KMS_KES_KEY_NAME
key for performing SSE.
mc mb ALIAS/encryptedbucket
mc encrypt set SSE-S3 ALIAS/encryptedbucket
Replace ALIAS
with the alias
of the MinIO
deployment configured in the previous step.
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.
The following section describes each of the Key Encryption Service (KES) configuration settings for using GCP Secrets Manager as the root Key Management Service (KMS) for SSE:
The following YAML describes the minimum required fields for configuring GCP Secret Manager as an external KMS for supporting SSE.
Any field with value ${VARIABLE}
uses the environment variable
with matching name as the value. You can use this functionality to set
credentials without writing them to the configuration file.
address: 0.0.0.0:7373
root: ${ROOT_IDENTITY}
tls:
key: kes-server.key
cert: kes-server.cert
policy:
minio-server:
allow:
- /v1/key/create/*
- /v1/key/generate/*
- /v1/key/decrypt/*
identities:
- ${MINIO_IDENTITY}
keys:
- name: "minio-encryption-key-alpha"
- name: "minio-encryption-key-baker"
- name: "minio-encryption-key-charlie"
keystore:
gcp:
secretmanager:
project_id: "${GCPPROJECTID}"
credentials:
client_email: "${GCPCLIENTEMAIL}"
client_id: "${GCPCLIENTID}"
private_key_id: "${GCPPRIVATEKEYID}"
private_key: "${GCPPRIVATEKEY}"
Key |
Description |
---|---|
|
The network address and port on which the KES server listens to on startup.
Defaults to port |
|
The identity for the KES superuser (root) identity. Clients connecting
with a TLS certificate whose hash ( You can specify |
|
The TLS private key and certificate used by KES for establishing
TLS-secured communications. Specify the full path to both the private |
|
Specify one or more policies to control access to the KES server. MinIO SSE requires access to only the following KES cryptographic APIs:
You can restrict the range of key names MinIO can create as part of performing
SSE by specifying a prefix to replace 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 GCP Secret Manager
|
This work is licensed under a Creative Commons Attribution 4.0 International License.
©2020-Present, MinIO, Inc.