Skip to content

Commit baf0bd6

Browse files
committed
kbs/resource: Add nebula plugin
The nebula plugin can be used to deliver credentials for nodes (confidential PODs or VMs) to join a Nebula overlay network. Within the nebula network, the communication between nodes is automatically encrypted by Nebula. A nebula credential can be requested using the kbs-client: kbs-client --url http://127.0.0.1:8080 \ get-resource \ --path 'plugin/nebula/credential?ip[ip]=10.11.12.13&ip[netbits]=21&name=pod1' at least the IPv4 address (in CIDR notation) and the name of the node must be provided in the query string. The other parameters supported can be found in the struct NebulaCredentialParams. After receiving a credential request, the nebula plugin will call the nebula-cert binary to create a key pair and sign a certificate using the Nebula CA. The generated node.crt and node.key, as well as the ca.rt are then returned to the caller. During the nebula-plugin initialization, a self signed Nebula CA can be created if 'ca_generation_policy = 1' in the nebula-config.toml, the file contains all parameters supported. Another option is to pre-install a ca.key and ca.crt, and set 'ca_generation_policy = 2'. The nebula-plugin cargo feature is set by default, however the plugin itself is not initialized by default. In order to initialize it, you need to add 'nebula' to 'manager_plugin_config.enabled_plugins' in the kbs-config.toml. Closes #396 Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com>
1 parent 6a8cc31 commit baf0bd6

8 files changed

Lines changed: 556 additions & 3 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
@@ -40,6 +40,7 @@ reqwest = "0.12"
4040
rstest = "0.18.1"
4141
serde = { version = "1.0", features = ["derive"] }
4242
serde_json = "1.0.89"
43+
serde_qs = "0.13.0"
4344
serde_with = { version = "1.11.0", features = ["base64", "hex"] }
4445
serial_test = "0.9.0"
4546
sha2 = "0.10"

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ services:
1818
- ./kbs/data/kbs-plugin:/opt/confidential-containers/kbs/plugin:rw
1919
- ./kbs/config/public.pub:/opt/confidential-containers/kbs/user-keys/public.pub
2020
- ./kbs/config/docker-compose/kbs-config.toml:/etc/kbs/kbs-config.toml
21+
- ./kbs/config/plugin/nebula-config.toml:/etc/kbs/plugin/nebula-config.toml
2122
depends_on:
2223
- as
2324

kbs/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ rustls = ["actix-web/rustls", "dep:rustls", "dep:rustls-pemfile"]
4141

4242
# Use openssl crypto stack for KBS
4343
openssl = ["actix-web/openssl", "dep:openssl"]
44+
nebula-plugin = []
4445

4546
# Use aliyun KMS as KBS backend
4647
aliyun = ["kms/aliyun"]
@@ -76,16 +77,17 @@ semver = "1.0.16"
7677
serde = { workspace = true, features = ["derive"] }
7778
serde_json.workspace = true
7879
strum.workspace = true
80+
serde_qs.workspace = true
7981
thiserror.workspace = true
8082
time = { version = "0.3.23", features = ["std"] }
8183
tokio.workspace = true
8284
tonic = { workspace = true, optional = true }
8385
uuid = { version = "1.2.2", features = ["serde", "v4"] }
8486
openssl = { version = "0.10.46", optional = true }
87+
tempfile.workspace = true
8588

8689
[dev-dependencies]
87-
tempfile.workspace = true
8890
rstest.workspace = true
8991

9092
[build-dependencies]
91-
tonic-build = { workspace = true, optional = true }
93+
tonic-build = { workspace = true, optional = true }
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Required: <String>
2+
# CA certificate path
3+
crt_path = "/opt/confidential-containers/kbs/plugin/nebula/ca/ca.crt"
4+
5+
# Required: <String>
6+
# CA key path
7+
key_path = "/opt/confidential-containers/kbs/plugin/nebula/ca/ca.key"
8+
9+
# Required: <u32>
10+
# Certificate Authority generation policy
11+
#
12+
# 1 = Create a self signed CA only if
13+
# crt_path/key_path not found
14+
#
15+
# 2 = Never generate self signed CA as
16+
# both crt_path and key_path are pre-installed
17+
ca_generation_policy = 1
18+
19+
[self_signed_ca_config]
20+
21+
# Required: <String>
22+
# Name of the certificate authority
23+
name = "Nebula CA for Trustee KBS"
24+
25+
# Optional: <u32>
26+
# Argon2 iterations parameter used for encrypted
27+
# private key passphrase (default 1)
28+
## argon_iterations = 1
29+
30+
# Optional: <u32>
31+
# Argon2 memory parameter (in KiB) used for encrypted
32+
# private key passphrase (default 2097152)
33+
## argon_memory = 2097152
34+
35+
# Optional: <u32>
36+
# Argon2 parallelism parameter used for encrypted private
37+
# key passphrase (default 4)
38+
## argon_parallelism = 4
39+
40+
# Optional: <String>
41+
# EdDSA/ECDSA Curve (25519, P256) (default "25519")
42+
## curve = "25519"
43+
44+
# Optional: <String>
45+
# Amount of time the certificate should be valid for.
46+
# Valid time units are seconds:
47+
# "s", minutes: "m", hours: "h" (default 8760h0m0s)
48+
## duration = "8760h0m0s"
49+
50+
# Optional: <String>
51+
# Comma separated list of groups. This will limit which
52+
# groups subordinate certs can use
53+
## groups = "servers,ssh"
54+
55+
# Optional: <String>
56+
# Comma separated list of ipv4 address and network
57+
# in CIDR notation. This will limit which ipv4 addresses and
58+
# networks subordinate certs can use for ip addresses
59+
## ips = "192.168.100.10/24"
60+
61+
# Optional: <String>
62+
# Path to write a QR code image (png) of the certificate
63+
## out_qr = "/opt/confidential-containers/kbs/plugin/nebula/ca/ca.png"
64+
65+
# Optional: <String>
66+
# Comma separated list of ipv4 address and network
67+
# in CIDR notation. This will limit which ipv4 addresses and
68+
# networks subordinate certs can use in subnets
69+
## subnets = "192.168.86.0/24"

kbs/docker/coco-as-grpc/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM rust:latest as builder
22
ARG ARCH=x86_64
33
ARG HTTPS_CRYPTO=rustls
44
ARG ALIYUN=false
5-
ARG PLUGINS=""
5+
ARG PLUGINS="nebula-plugin"
66

77
WORKDIR /usr/src/kbs
88
COPY . .
@@ -13,8 +13,13 @@ RUN apt-get update && apt install -y protobuf-compiler git
1313
RUN cd kbs && make AS_FEATURE=coco-as-grpc HTTPS_CRYPTO=${HTTPS_CRYPTO} POLICY_ENGINE=opa ALIYUN=${ALIYUN} PLUGINS=${PLUGINS} && \
1414
make install-kbs
1515

16+
# Install Nebula
17+
RUN wget https://github.com/slackhq/nebula/releases/download/v1.8.2/nebula-linux-amd64.tar.gz
18+
RUN tar -C /usr/local/bin -xzf nebula-linux-amd64.tar.gz
19+
1620
FROM ubuntu:22.04
1721

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

2024
COPY --from=builder /usr/local/bin/kbs /usr/local/bin/kbs
25+
COPY --from=builder /usr/local/bin/nebula-cert /usr/local/bin/nebula-cert

kbs/docs/config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ List of supported plugins that can be added to `enabled_plugins`.
9292

9393
| Plugin name | Plugin Description | Available Cargo Features |
9494
|-----------------------|--------------------------------------------------|-------------------------------|
95+
| `nebula` | Provide resources to support the creation of a Nebula encrypted overlay network between nodes. | `nebula-plugin` |
9596

9697
### Native Attestation
9798

0 commit comments

Comments
 (0)