Skip to content

Commit d1c8e9f

Browse files
author
Andreas Auernhammer
authored
update KMS guide to work with latest KES changes (minio#9498)
This commit updates the KMS guide to reflect the latest changes in KES. Based on internal design meetings we made some adjustments to the overall KES configuration. This commit ensures that the KMS guide contains a working KES demo-setup with Vault.
1 parent 83ccae6 commit d1c8e9f

File tree

1 file changed

+104
-113
lines changed

1 file changed

+104
-113
lines changed

docs/kms/README.md

Lines changed: 104 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,26 @@ managed by the KMS.
1111
## Architecture and Concepts
1212

1313
The KMS decouples MinIO as an application-facing storage system from the secure key storage and
14-
may be managed by a dedicated security team. In general, the MinIO-KMS infrastructure looks like this:
14+
may be managed by a dedicated security team. MinIO supports commonly-used KMS implementations, like
15+
[Hashicorp Vault](https://www.vaultproject.io/) via our [KES project](https://github.com/minio/kes).
16+
KES makes it possible to scale your KMS horizontally with your storage infrastructure (MinIO clusters).
17+
In general, the MinIO-KMS infrastructure looks like this:
1518
```
16-
+-------+ +-----+
17-
| MinIO +-------+ KMS |
18-
+-------+ +-----+
19+
┌─────────┐ ┌────────────┐ ┌─────────┐
20+
MinIO ├─────────┤ KES Server ├─────────┤ KMS
21+
└─────────┘ └────────────┘ └─────────┘
1922
```
2023

21-
If you scale your storage infrastructure to multiple MinIO clusters your architecture should look like this:
24+
When you scale your storage infrastructure to multiple MinIO clusters your architecture should look like this:
2225
```
23-
+-------+ +-------+
24-
| MinIO +----+ +----+ MinIO |
25-
+-------+ | +-----+ | +-------+
26-
+---+ KMS +---+
27-
+-------+ | +-----+ | +-------+
28-
| MinIO +----+ +----+ MinIO |
29-
+-------+ +-------+
26+
┌────────────┐
27+
│ ┌──────────┴─┬─────╮ ┌────────────┐
28+
└─┤ ┌──────────┴─┬───┴──────────┤ ┌──────────┴─┬─────────────────╮
29+
└─┤ ┌──────────┴─┬─────┬──────┴─┤ KES Server ├─────────────────┤
30+
└─┤ MinIO ├─────╯ └────────────┘ ┌────┴────┐
31+
└────────────┘ │ KMS │
32+
└─────────┘
3033
```
31-
32-
MinIO supports commonly-used KMS implementations, like [AWS-KMS](https://aws.amazon.com/kms/) or
33-
[Hashicorp Vault](https://www.vaultproject.io/) via our [KES project](https://github.com/minio/kes/wiki).
34-
KES makes it possible to scale your KMS horizontally with your storage infrastructure (MinIO clusters).
35-
Therefore, it wraps around the KMS implementation like this:
36-
```
37-
+-------+ +-------+
38-
| MinIO | | MinIO |
39-
+---+---+ +---+---+
40-
| |
41-
+----+-------------------------+----+---- KMS
42-
| | | |
43-
| +--+--+ +--+--+ |
44-
| | KES +--+ +--+ KES | |
45-
| +-----+ | +-------+ | +-----+ |
46-
| +--+ Vault +--+ |
47-
| +-----+ | +-------+ | +-----+ |
48-
| | KES +--+ +--+ KES | |
49-
| +--+--+ +--+--+ |
50-
| | | |
51-
+----+-------------------------+----+---- KMS
52-
| |
53-
+---+---+ +---+---+
54-
| MinIO | | MinIO |
55-
+-------+ +-------+
56-
```
5734
Observe that all MinIO clusters only have a connection to "their own" KES instance and no direct access to Vault (as one possible KMS implementation).
5835
Each KES instance will handle all encrypton/decryption requests made by "its" MinIO cluster such that the central KMS implementation does not have to handle
5936
a lot of traffic. Instead, each KES instance will use the central KMS implementation as secure key store and fetches the required master keys from it.
@@ -77,7 +54,7 @@ This guide shows how to set up three different servers on the same machine:
7754
### 1 Prerequisites
7855

7956
Install MinIO, KES and Vault. For MinIO take a look at the [MinIO quickstart guide](https://docs.min.io/docs/minio-quickstart-guide).
80-
Then download the [latest KES binary](https://github.com/minio/kes/releases/latest/) and the [latest Vault binary](https://github.com/hashicorp/vault/releases/latest/)
57+
Then [install KES](https://github.com/minio/kes#install) and download the [latest Vault binary](https://www.vaultproject.io/downloads)
8158
for your OS and platform.
8259

8360
### 2 Generate TLS certificates
@@ -88,30 +65,44 @@ TLS connections between MinIO, KES and Vault. Therefore, we need to generate at
8865
#### 2.1 Generate a TLS certificate for Vault
8966

9067
To generate a new private key for Vault's certificate run the following openssl command:
91-
```
68+
```sh
9269
openssl ecparam -genkey -name prime256v1 | openssl ec -out vault-tls.key
9370
```
9471

9572
Then generate a new TLS certificate for the private/public key pair via:
96-
```
97-
openssl req -new -x509 -days 365 -key vault-tls.key -out vault-tls.crt -subj "/C=US/ST=state/L=location/O=organization/CN=localhost"
98-
```
99-
> You may want to adjust the X.509 subject (`-subj` parameter). Note that this is a self-signed certificate. For production deployments
100-
> this certificate should be issued by a CA.
73+
```sh
74+
openssl req -new -x509 -days 365 \
75+
-key vault-tls.key \
76+
-out vault-tls.crt \
77+
-subj "/C=/ST=/L=/O=/CN=localhost" \
78+
-addext "subjectAltName = IP:127.0.0.1"
79+
```
80+
> You can ignore output messages like: req: No value provided for Subject Attribute C, skipped.
81+
> OpenSSL just tells you that you haven't specified a country, state, a.s.o for the certificate subject.
82+
> You may want to adjust the X.509 subject (`-subj` parameter) and subject alternative name (SAN).
83+
> Note that this is a self-signed certificate. For production deployments this certificate should be
84+
> issued by a CA.
10185
10286
#### 2.2 Generate a TLS certificate for KES
10387

10488
To generate a new private key for KES's certificate run the following openssl command:
105-
```
89+
```sh
10690
openssl ecparam -genkey -name prime256v1 | openssl ec -out kes-tls.key
10791
```
10892

10993
Then generate a new TLS certificate for the private/public key pair via:
110-
```
111-
openssl req -new -x509 -days 365 -key kes-tls.key -out kes-tls.crt -subj "/C=US/ST=state/L=location/O=organization/CN=localhost"
112-
```
113-
> You may want to adjust the X.509 subject (`-subj` parameter). Note that this is a self-signed certificate. For production deployments
114-
> this certificate should be issued by a CA.
94+
```sh
95+
openssl req -new -x509 -days 365 \
96+
-key kes-tls.key \
97+
-out kes-tls.crt \
98+
-subj "/C=/ST=/L=/O=/CN=localhost" \
99+
-addext "subjectAltName = IP:127.0.0.1"
100+
```
101+
> You can ignore output messages like: req: No value provided for Subject Attribute C, skipped.
102+
> OpenSSL just tells you that you haven't specified a country, state, a.s.o for the certificate subject.
103+
> You may want to adjust the X.509 subject (`-subj` parameter) and subject alternative name (SAN).
104+
> Note that this is a self-signed certificate. For production deployments this certificate should be
105+
> issued by a CA.
115106
116107
#### 2.3 Generate a TLS certificate for MinIO (Optional)
117108

@@ -125,12 +116,12 @@ Checkout the [MinIO TLS guide](https://docs.min.io/docs/how-to-secure-access-to-
125116
On unix-like systems, Vault uses the `mlock` syscall to prevent the OS from writing in-memory data
126117
to disk (swapping). Therefore, you should give the Vault executable the ability to use the `mlock`
127118
syscall without running the process as root. To do so run:
128-
```
119+
```sh
129120
sudo setcap cap_ipc_lock=+ep $(readlink -f $(which vault))
130121
```
131122

132123
Then create the Vault config file:
133-
```
124+
```sh
134125
cat > vault-config.json <<EOF
135126
{
136127
"api_addr": "https://127.0.0.1:8200",
@@ -156,14 +147,14 @@ EOF
156147
> backend - like [etcd](https://www.vaultproject.io/docs/configuration/storage/etcd/) or [consul](https://learn.hashicorp.com/vault/operations/ops-vault-ha-consul).
157148
158149
Finally, start the Vault server via:
159-
```
150+
```sh
160151
vault server -config vault-config.json
161152
```
162153

163154
#### 3.1 Initialize and unseal Vault
164155

165156
In a separate terminal window set the `VAULT_ADDR` env. variable to your Vault server:
166-
```
157+
```sh
167158
export VAULT_ADDR='https://127.0.0.1:8200'
168159
```
169160

@@ -172,7 +163,7 @@ certificate. When Vault serves a TLS certificate that has been issued by a CA th
172163
by your machine - e.g. Let's Encrypt - then you don't need to run this command.
173164

174165
Then initialize Vault via:
175-
```
166+
```sh
176167
vault operator init
177168
```
178169

@@ -203,12 +194,12 @@ existing unseal keys shares. See "vault operator rekey" for more information.
203194
```
204195

205196
Now, set the env. variable `VAULT_TOKEN` to the root token printed by the command before:
206-
```
197+
```sh
207198
export VAULT_TOKEN=s.zaU4Gbcu0Wh46uj2V3VuUde0
208199
```
209200

210201
Then use any of the previously generated key shares to unseal Vault.
211-
```
202+
```sh
212203
vault operator unseal eyW/+8ZtsgT81Cb0e8OVxzJAQP5lY7Dcamnze+JnWEDT
213204
vault operator unseal 0tZn+7QQCxphpHwTm6/dC3LpP5JGIbYl6PK8Sy79R+P2
214205
vault operator unseal cmhs+AUMXUuB6Lzsvgcbp3bRT6VDGQjgCBwB2xm0ANeF
@@ -221,23 +212,23 @@ and able to process requests.
221212

222213
The cryptographic master keys (but not the object encryption keys) will be stored
223214
at Vault. Therefore, we need to enable Vault's K/V backend. To do so run:
224-
```
215+
```sh
225216
vault secrets enable kv
226217
```
227218

228219
#### 3.3 Enable AppRole authentication
229220

230221
Since we want connect one/multiple KES server to Vault later, we have to enable
231222
AppRole authentication. To do so run:
232-
```
223+
```sh
233224
vault auth enable approle
234225
```
235226

236227
#### 3.4 Create an access policy for the K/V engine
237228

238229
The following policy determines how an application (i.e. KES server) can interact
239230
with Vault.
240-
```
231+
```sh
241232
cat > minio-kes-policy.hcl <<EOF
242233
path "kv/minio/*" {
243234
capabilities = [ "create", "read", "delete" ]
@@ -251,7 +242,7 @@ EOF
251242
> and security requirements.
252243
253244
Then we upload the policy to Vault:
254-
```
245+
```sh
255246
vault policy write minio-key-policy ./minio-kes-policy.hcl
256247
```
257248

@@ -262,23 +253,23 @@ The application (i.e. KES server) will authenticate to Vault via the AppRole rol
262253
and secret ID and is only allowed to perform operations granted by the specific policy.
263254

264255
So, we first create a new role for our KES server:
265-
```
256+
```sh
266257
vault write auth/approle/role/kes-role token_num_uses=0 secret_id_num_uses=0 period=5m
267258
```
268259

269260
Then we bind a policy to the role:
270-
```
261+
```sh
271262
vault write auth/approle/role/kes-role policies=minio-key-policy
272263
```
273264

274265
Finally, we request an AppRole role ID and secret ID from Vault.
275266
First, the role ID:
276-
```
267+
```sh
277268
vault read auth/approle/role/kes-role/role-id
278269
```
279270

280271
Then the secret ID:
281-
```
272+
```sh
282273
vault write -f auth/approle/role/kes-role/secret-id
283274
```
284275
> We are only interested in the `secret_id` - not in the `secret_id_accessor`.
@@ -288,7 +279,7 @@ vault write -f auth/approle/role/kes-role/secret-id
288279
Similar to Vault, KES uses the `mlock` syscall on linux systems to prevent the OS from writing in-memory
289280
data to disk (swapping). Therefore, you should give the KES executable the ability to use the `mlock`
290281
syscall without running the process as root. To do so run:
291-
```
282+
```sh
292283
sudo setcap cap_ipc_lock=+ep $(readlink -f $(which kes))
293284
```
294285

@@ -299,15 +290,15 @@ The KES server will accept/reject the connection attempt and applies policies ba
299290

300291
Therefore, each MinIO cluster needs a X.509 TLS certificate for client authentication. You can create a
301292
(self-signed) certificate by running:
302-
```
293+
```sh
303294
kes tool identity new MinIO --key=minio.key --cert=minio.cert --time=8760h
304295
```
305296
> Note that *MinIO* is the [subject name](https://en.wikipedia.org/wiki/X.509#Structure_of_a_certificate).
306297
> You may choose a more appropriate name for your deployment scenario. Also, for production deployments we
307298
> recommend to get a TLS certificate for client authentication that has been issued by a CA.
308299
309300
To get the identity of a X.509 certificate run:
310-
```
301+
```sh
311302
kes tool identity of minio.cert
312303
```
313304
> This command works with any (valid) X.509 certificate - regardless how it has been created - and
@@ -319,56 +310,56 @@ kes tool identity of minio.cert
319310
#### 4.2 Create the KES config file
320311

321312
Now, we can create the KES config file and start the KES server.
322-
```
323-
cat > kes-config.toml <<EOF
324-
# The address:port of the kes server - i.e. on the local machine.
325-
address = "127.0.0.1:7373"
326-
327-
[tls]
328-
key = "./kes-tls.key"
329-
cert = "./kes-tls.crt"
330-
331-
[policy.minio]
332-
paths = [
333-
"/v1/key/create/minio-*",
334-
"/v1/key/generate/minio-*",
335-
"/v1/key/decrypt/minio-*"
336-
]
337-
identities = [ "dd46485bedc9ad2909d2e8f9017216eec4413bc5c64b236d992f7ec19c843c5f" ]
338-
339-
[cache.expiry]
340-
all = "5m"
341-
unused = "20s"
342-
343-
[keystore.vault]
344-
address = "https://127.0.0.1:8200" # The Vault endpoint - i.e. https://127.0.0.1:8200
345-
name = "minio" # The domain resp. prefix at Vault's K/V backend
346-
347-
[keystore.vault.approle]
348-
id = "" # Your AppRole Role ID
349-
secret = "" # Your AppRole Secret ID
350-
retry = "15s" # Duration until the server tries to re-authenticate after connection loss.
351-
352-
[keystore.vault.tls]
353-
ca = "./vault-tls.crt" # Since we use self-signed certificates
354-
355-
[keystore.vault.status]
356-
ping = "10s"
357-
358-
EOF
359-
```
360-
> Please change the value of `identities` under `policy.minio` to the identity of your `minio.cert`.
313+
```yaml
314+
# The TCP address (ip:port) for the KES server to listen on.
315+
address: 0.0.0.0:7373
316+
317+
tls:
318+
key: kes-tls.key
319+
cert: kes-tls.crt
320+
321+
policy:
322+
minio:
323+
paths:
324+
- /v1/key/create/minio-*
325+
- /v1/key/generate/minio-*
326+
- /v1/key/decrypt/minio-*
327+
identities:
328+
- dd46485bedc9ad2909d2e8f9017216eec4413bc5c64b236d992f7ec19c843c5f
329+
330+
cache:
331+
expiry:
332+
any: 5m0s
333+
unused: 20s
334+
335+
keys:
336+
vault:
337+
endpoint: https://127.0.0.1:8200 # The Vault endpoint - i.e. https://127.0.0.1:8200
338+
prefix: minio # The domain resp. prefix at Vault's K/V backend
339+
340+
approle:
341+
id: "" # Your AppRole Role ID
342+
secret: "" # Your AppRole Secret ID
343+
retry: 15s # Duration until the server tries to re-authenticate after connection loss.
344+
345+
tls:
346+
ca: vault-tls.crt # Since we use self-signed certificates
347+
348+
status:
349+
ping: 10s
350+
```
351+
> Please change the value of `identities` in the `policy` section to the identity of your `minio.cert`.
361352
> Also, insert the AppRole role ID and secret ID that you have created previously during the Vault setup.
362-
> You can find a documented config file with all available parameters [here](https://github.com/minio/kes/blob/master/server-config.toml).
353+
> You can find a documented config file with all available parameters [here](https://github.com/minio/kes/blob/master/server-config.yaml).
363354

364355
Finally, start the KES server via:
365356
```
366-
kes server --config=kes-config.toml --mlock --root=disabled --mtls-auth=ignore
357+
kes server --config=kes-config.yaml --mlock --root=disabled --auth=off
367358
```
368359
> Note that we effectively disable the special *root* identity since we don't need it.
369-
> For more information about KES identities checkout: [KES Identities](https://github.com/minio/kes/wiki#identities)
370-
> Further, note that we pass `--mtls-auth=ignore` since the client X.509 certificate
371-
> is a self-signed certificate.
360+
> For more information about the KES access control model and identities checkout:
361+
> [KES Concepts](https://github.com/minio/kes/wiki/Concepts). Further, note that we
362+
> disable `--auth=off` since the client X.509 certificate is a self-signed certificate.
372363

373364
#### 4.3 Create a new master key
374365

0 commit comments

Comments
 (0)