Skip to content

Commit a48c6de

Browse files
committed
kbs: Add nebula_ca plugin
The plugin can create a Nebula certificate authority to provide credentials for CoCo PODs (or VMs) that want to join a Nebula encrypted overlay network. A credential is provided only for attested CoCo PODs. The steps below can be used to build and start trustee with support for the 'nebula-ca' plugin. The first step builds the KBS with the 'nebula-ca' cargo feature enabled. The second step configures the plugin as explained in the kbs/docs/config.md. $ docker compose build --build-arg NEBULA_CA=true $ cat >> kbs/config/docker-compose/kbs-config.toml << EOF [[plugins]] name = "nebula-ca" nebula_cert_bin_path = "/usr/local/bin/nebula-cert" work_dir = "/opt/confidential-containers/kbs/nebula-ca" [plugins.self_signed_ca] name = "Nebula CA for Trustee KBS" EOF $ docker compose up The nebula-ca is a self signed certificate authority. When the plugin is started, it will create the CA key and certificate based on the configuration provided in the kbs-config.toml file, unless the ${work_dir}/ca/ca.{key,crt} already exists. A credential can be requested via GET /kbs/v0/nebula-ca/credential. Additional parameters can be provided via query string: /// Required: name of the cert, usually hostname or podname name: String, /// Required: IPv4 address and network in CIDR notation to assign the cert ip: String, /// Optional: how long the cert should be valid for. /// The default is 1 second before the signing cert expires. /// Valid time units are seconds: "s", minutes: "m", hours: "h". duration: Option<String>, /// Optional: comma separated list of groups. groups: Option<String>, /// Optional: comma separated list of ipv4 address and network in CIDR notation. /// Subnets this cert can serve for subnets: Option<String>, For example, the GET below provides two required parameters via query string: name and IP address (CIDR notation). Other examples can be found in the unit test cases defined in the nebula_ca.rs file. GET /kbs/v0/nebula-ca/credential?name=podA&ip=10.9.8.2/21 Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com>
1 parent cc57384 commit a48c6de

10 files changed

Lines changed: 542 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ reqwest = { version = "0.12", default-features = false, features = [
5050
rstest = "0.18.1"
5151
serde = { version = "1.0", features = ["derive"] }
5252
serde_json = "1.0.132"
53+
serde_qs = "0.13.0"
5354
serde_with = { version = "1.11.0", features = ["base64", "hex"] }
5455
serial_test = "0.9.0"
5556
sha2 = "0.10"

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ services:
1414
- "8080:8080"
1515
volumes:
1616
- ./kbs/data/kbs-storage:/opt/confidential-containers/kbs/repository:rw
17+
- ./kbs/data/nebula-ca:/opt/confidential-containers/kbs/nebula-ca:rw
1718
- ./kbs/config/public.pub:/opt/confidential-containers/kbs/user-keys/public.pub
1819
- ./kbs/config/docker-compose/kbs-config.toml:/etc/kbs-config.toml
1920
depends_on:

kbs/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ aliyun = ["kms/aliyun"]
3333
# Use pkcs11 resource backend to store secrets in an HSM
3434
pkcs11 = ["cryptoki"]
3535

36+
# Use Nebula CA to provide credentials for nodes (pods) to join a Nebula overlay network
37+
nebula-ca = []
38+
3639
[dependencies]
3740
actix-web = { workspace = true, features = ["openssl"] }
3841
actix-web-httpauth.workspace = true
@@ -59,10 +62,12 @@ regorus.workspace = true
5962
reqwest = { workspace = true, features = ["json"] }
6063
rsa = { version = "0.9.2", features = ["sha2"] }
6164
scc = "2"
65+
serde_qs.workspace = true
6266
semver = "1.0.16"
6367
serde = { workspace = true, features = ["derive"] }
6468
serde_json.workspace = true
6569
strum.workspace = true
70+
tempfile.workspace = true
6671
thiserror.workspace = true
6772
time = { version = "0.3.23", features = ["std"] }
6873
tokio.workspace = true
@@ -89,7 +94,6 @@ attestation-service = { path = "../attestation-service", default-features = fals
8994

9095

9196
[dev-dependencies]
92-
tempfile.workspace = true
9397
rstest.workspace = true
9498
reference-value-provider-service.path = "../rvps"
9599

kbs/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
AS_TYPE ?= coco-as
22
ALIYUN ?= false
3+
NEBULA_CA ?= false
34

45
BUILD_ARCH := $(shell uname -m)
56
ARCH ?= $(shell uname -m)
@@ -48,6 +49,10 @@ ifeq ($(ALIYUN), true)
4849
FEATURES += aliyun
4950
endif
5051

52+
ifeq ($(NEBULA_CA), true)
53+
FEATURES += nebula-ca
54+
endif
55+
5156
ifndef CLI_FEATURES
5257
ifdef ATTESTER
5358
CLI_FEATURES = "sample_only,$(ATTESTER)"

kbs/docker/coco-as-grpc/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ FROM --platform=$BUILDPLATFORM rust:latest AS builder
22
ARG BUILDPLATFORM=linux/amd64
33
ARG ARCH=x86_64
44
ARG ALIYUN=false
5+
ARG NEBULA_CA=false
6+
ARG NEBULA_VERSION=v1.9.5
57

68
WORKDIR /usr/src/kbs
79
COPY . .
@@ -17,11 +19,18 @@ RUN if [ $(uname -m) != ${ARCH} ]; then \
1719
apt-get install -y libssl-dev:${OS_ARCH}; fi
1820

1921
# Build and Install KBS
20-
RUN cd kbs && make AS_FEATURE=coco-as-grpc ALIYUN=${ALIYUN} ARCH=${ARCH} && \
22+
RUN cd kbs && make AS_FEATURE=coco-as-grpc ALIYUN=${ALIYUN} ARCH=${ARCH} NEBULA_CA=${NEBULA_CA} && \
2123
make ARCH=${ARCH} install-kbs
2224

25+
# Download and install Nebula
26+
RUN if [ "${NEBULA_CA}" = "true" ]; then \
27+
curl -fSLO https://github.com/slackhq/nebula/releases/download/${NEBULA_VERSION}/nebula-$(echo ${BUILDPLATFORM} | sed 's/\//-/').tar.gz && \
28+
tar -C /usr/local/bin -xzf nebula-$(echo "${BUILDPLATFORM}" | sed 's/\//-/').tar.gz; \
29+
fi
30+
2331
FROM ubuntu:22.04
2432

2533
LABEL org.opencontainers.image.source="https://github.com/confidential-containers/trustee/kbs"
2634

2735
COPY --from=builder /usr/local/bin/kbs /usr/local/bin/kbs
36+
COPY --from=builder /usr/local/bin/nebula-cert* /usr/local/bin/nebula-cert

kbs/docs/config.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,35 @@ This is also called "Repository" in old versions. The properties to be configure
250250
| `password` | String | AAP client key password | Yes | `8f9989c18d27...` |
251251
| `cert_pem` | String | CA cert for the KMS instance | Yes | `-----BEGIN CERTIFICATE----- ...` |
252252

253+
#### Nebula CA Configuration
254+
255+
The `name` field is `nebula-ca` to enable this plugin.
256+
257+
The plugin can generate credentials for CoCo PODs (or VMs) that want to
258+
join a Nebula encrypted overlay network. The properties below can be
259+
used to configure the plugin.
260+
261+
| Property | Type | Description | Required | Example |
262+
|------------------------|--------|-----------------------------------|----------|-----------------------------------------------------|
263+
| `nebula_cert_bin_path` | String | nebula-cert binary path | Yes | `/usr/local/bin/nebula-cert` |
264+
| `work_dir` | String | This plugin work directory, it requires `rw` permission | Yes | `/opt/confidential-containers/kbs/nebula-ca` |
265+
266+
The following properties can be set under the `[self_signed_ca]` plugin section to configure the Nebula Certificate Authority.
267+
The Nebula CA will be re-created only if `${work_dir}/ca/ca.{key,crt}` are not found.
268+
269+
| Property | Type | Description | Required | Default | Example |
270+
|---------------------|---------|-----------------------------------|----------|-----------------------------------------------------|
271+
| `name` | String | Name of the certificate authority | Yes | | `Nebula Ca for Trustee KBS` |
272+
| `argon_iterations` | Integer | Argon2 iterations parameter used for encrypted private key passphrase | No | 1 | |
273+
| `argon_memory` | Integer | Argon2 memory parameter (in KiB) used for encrypted private key passphrase | No | 2097152 | |
274+
| `argon_parallelism` | Integer | Argon2 parallelism parameter used for encrypted private key passphrase | No | 4 | |
275+
| `curve` | String | EdDSA/ECDSA Curve (25519, P256) | No | `25519` | |
276+
| `duration` | String | Amount of time the certificate should be valid for. Valid time units are: <hours>"h"<minutes>"m"<seconds>"s" | No | `8760h0m0s` | |
277+
| `groups` | String | Comma separated list of groups. This will limit which groups subordinate certs can use | No | | `server,ssh` |
278+
| `ips` | String | Comma separated list of ipv4 address and network in CIDR notation. This will limit which ipv4 addresses and networks subordinate certs can use for ip addresses | No | | `192.168.100.10/24,192.168.100.15/24` |
279+
| `out_qr` | String | Path to write a QR code image (png) of the certificate | No | | `/opt/confidential-containers/kbs/nebula_ca/ca_qr.crt`|
280+
| `subnets` | String | Comma separated list of ipv4 address and network in CIDR notation. This will limit which ipv4 addresses and networks subordinate certs can use in subnets | No | | `192.168.86.0/24` |
281+
253282
## Configuration Examples
254283

255284
Using a built-in CoCo AS:
@@ -283,6 +312,13 @@ policy_engine = "opa"
283312
name = "resource"
284313
type = "LocalFs"
285314
dir_path = "/opt/confidential-containers/kbs/repository"
315+
316+
[[plugins]]
317+
name = "nebula-ca"
318+
nebula_cert_bin_path = "/usr/local/bin/nebula-cert"
319+
work_dir = "/opt/confidential-containers/kbs/nebula-ca"
320+
[plugins.settings]
321+
name = "Nebula CA for Trustee KBS"
286322
```
287323

288324
Using a remote CoCo AS:
@@ -302,6 +338,13 @@ as_addr = "http://127.0.0.1:50004"
302338
name = "resource"
303339
type = "LocalFs"
304340
dir_path = "/opt/confidential-containers/kbs/repository"
341+
342+
[[plugins]]
343+
name = "nebula-ca"
344+
nebula_cert_bin_path = "/usr/local/bin/nebula-cert"
345+
work_dir = "/opt/confidential-containers/kbs/nebula-ca"
346+
[plugins.settings]
347+
name = "Nebula CA for Trustee KBS"
305348
```
306349

307350
Running with Intel Trust Authority attestation service:

kbs/src/plugins/implementations/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
// SPDX-License-Identifier: Apache-2.0
44

5+
#[cfg(feature = "nebula-ca")]
6+
pub mod nebula_ca;
57
pub mod resource;
68
pub mod sample;
79

10+
#[cfg(feature = "nebula-ca")]
11+
pub use nebula_ca::{NebulaCa, NebulaCaConfig};
812
pub use resource::{RepositoryConfig, ResourceStorage};
913
pub use sample::{Sample, SampleConfig};

0 commit comments

Comments
 (0)