Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nebula_ca plugin #539

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ reqwest = { version = "0.12", default-features = false, features = [
rstest = "0.18.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.132"
serde_qs = "0.13.0"
serde_with = { version = "1.11.0", features = ["base64", "hex"] }
serial_test = "0.9.0"
sha2 = "0.10"
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
- "8080:8080"
volumes:
- ./kbs/data/kbs-storage:/opt/confidential-containers/kbs/repository:rw
- ./kbs/data/nebula-ca:/opt/confidential-containers/kbs/nebula-ca:rw
- ./kbs/config/public.pub:/opt/confidential-containers/kbs/user-keys/public.pub
- ./kbs/config/docker-compose/kbs-config.toml:/etc/kbs-config.toml
depends_on:
Expand Down
6 changes: 5 additions & 1 deletion kbs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ aliyun = ["kms/aliyun"]
# Use pkcs11 resource backend to store secrets in an HSM
pkcs11 = ["cryptoki"]

# Use Nebula CA to provide credentials for nodes (pods) to join a Nebula overlay network
nebula-ca = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should have a convention for features that enable plugins. we could call this nebula-ca-plugin for instance

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree and I like nebula-ca-plugin


[dependencies]
actix-web = { workspace = true, features = ["openssl"] }
actix-web-httpauth.workspace = true
Expand All @@ -59,10 +62,12 @@ regorus.workspace = true
reqwest = { workspace = true, features = ["json"] }
rsa = { version = "0.9.2", features = ["sha2"] }
scc = "2"
serde_qs.workspace = true
semver = "1.0.16"
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
strum.workspace = true
tempfile.workspace = true
thiserror.workspace = true
time = { version = "0.3.23", features = ["std"] }
tokio.workspace = true
Expand All @@ -89,7 +94,6 @@ attestation-service = { path = "../attestation-service", default-features = fals


[dev-dependencies]
tempfile.workspace = true
rstest.workspace = true
reference-value-provider-service.path = "../rvps"

Expand Down
5 changes: 5 additions & 0 deletions kbs/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
AS_TYPE ?= coco-as
ALIYUN ?= false
NEBULA_CA ?= false

BUILD_ARCH := $(shell uname -m)
ARCH ?= $(shell uname -m)
Expand Down Expand Up @@ -48,6 +49,10 @@ ifeq ($(ALIYUN), true)
FEATURES += aliyun
endif

ifeq ($(NEBULA_CA), true)
FEATURES += nebula-ca
endif

ifndef CLI_FEATURES
ifdef ATTESTER
CLI_FEATURES = "sample_only,$(ATTESTER)"
Expand Down
11 changes: 10 additions & 1 deletion kbs/docker/coco-as-grpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM --platform=$BUILDPLATFORM rust:latest AS builder
ARG BUILDPLATFORM=linux/amd64
ARG ARCH=x86_64
ARG ALIYUN=false
ARG NEBULA_CA=false
ARG NEBULA_VERSION=v1.9.5

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

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

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

FROM ubuntu:22.04

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

COPY --from=builder /usr/local/bin/kbs /usr/local/bin/kbs
COPY --from=builder /usr/local/bin/nebula-cert* /usr/local/bin/nebula-cert
43 changes: 43 additions & 0 deletions kbs/docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,35 @@ This is also called "Repository" in old versions. The properties to be configure
| `password` | String | AAP client key password | Yes | `8f9989c18d27...` |
| `cert_pem` | String | CA cert for the KMS instance | Yes | `-----BEGIN CERTIFICATE----- ...` |

#### Nebula CA Configuration

The `name` field is `nebula-ca` to enable this plugin.

The plugin can generate credentials for CoCo PODs (or VMs) that want to
join a Nebula encrypted overlay network. The properties below can be
used to configure the plugin.

| Property | Type | Description | Required | Example |
|------------------------|--------|-----------------------------------|----------|-----------------------------------------------------|
| `nebula_cert_bin_path` | String | nebula-cert binary path | Yes | `/usr/local/bin/nebula-cert` |
| `work_dir` | String | This plugin work directory, it requires `rw` permission | Yes | `/opt/confidential-containers/kbs/nebula-ca` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to be required? It seems like we could have default values for both parameters.


The following properties can be set under the `[self_signed_ca]` plugin section to configure the Nebula Certificate Authority.
The Nebula CA will be re-created only if `${work_dir}/ca/ca.{key,crt}` are not found.

| Property | Type | Description | Required | Default | Example |
|---------------------|---------|-----------------------------------|----------|-----------------------------------------------------|
| `name` | String | Name of the certificate authority | Yes | | `Nebula Ca for Trustee KBS` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also seems like it could have a default value

| `argon_iterations` | Integer | Argon2 iterations parameter used for encrypted private key passphrase | No | 1 | |
| `argon_memory` | Integer | Argon2 memory parameter (in KiB) used for encrypted private key passphrase | No | 2097152 | |
| `argon_parallelism` | Integer | Argon2 parallelism parameter used for encrypted private key passphrase | No | 4 | |
| `curve` | String | EdDSA/ECDSA Curve (25519, P256) | No | `25519` | |
| `duration` | String | Amount of time the certificate should be valid for. Valid time units are: <hours>"h"<minutes>"m"<seconds>"s" | No | `8760h0m0s` | |
| `groups` | String | Comma separated list of groups. This will limit which groups subordinate certs can use | No | | `server,ssh` |
| `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` |
| `out_qr` | String | Path to write a QR code image (png) of the certificate | No | | `/opt/confidential-containers/kbs/nebula_ca/ca_qr.crt`|
| `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` |

## Configuration Examples

Using a built-in CoCo AS:
Expand Down Expand Up @@ -283,6 +312,13 @@ policy_engine = "opa"
name = "resource"
type = "LocalFs"
dir_path = "/opt/confidential-containers/kbs/repository"

[[plugins]]
name = "nebula-ca"
nebula_cert_bin_path = "/usr/local/bin/nebula-cert"
work_dir = "/opt/confidential-containers/kbs/nebula-ca"
[plugins.settings]
name = "Nebula CA for Trustee KBS"
```

Using a remote CoCo AS:
Expand All @@ -302,6 +338,13 @@ as_addr = "http://127.0.0.1:50004"
name = "resource"
type = "LocalFs"
dir_path = "/opt/confidential-containers/kbs/repository"

[[plugins]]
name = "nebula-ca"
nebula_cert_bin_path = "/usr/local/bin/nebula-cert"
work_dir = "/opt/confidential-containers/kbs/nebula-ca"
[plugins.settings]
name = "Nebula CA for Trustee KBS"
```

Running with Intel Trust Authority attestation service:
Expand Down
4 changes: 4 additions & 0 deletions kbs/src/plugins/implementations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "nebula-ca")]
pub mod nebula_ca;
pub mod resource;
pub mod sample;

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