Skip to content

Commit fc960a1

Browse files
Merge pull request #3 from acompany-develop/imamura/fix-setup-scripts
fix(scripts): fix and refactor setup scripts
2 parents 1e7bd4c + 7619ccf commit fc960a1

File tree

6 files changed

+65
-30
lines changed

6 files changed

+65
-30
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.DS_Store
22

3+
AWS_NitroEnclaves_Root-G1.zip
4+
root.pem
5+
36
target/
47
debug/

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL := /bin/bash
22

3-
.PHONY: help setup-docker setup-nitro-cli setup-client build-enclave build-proxy build-client run-enclave run-proxy run-client terminate-enclave
3+
.PHONY: help setup-docker setup-nitro-cli setup-client download-root-ca build-enclave build-proxy build-client run-enclave run-proxy run-client terminate-enclave
44

55
ENCLAVE_CID ?= 16
66
ENCLAVE_MEMORY ?= 512
@@ -13,16 +13,17 @@ help:
1313
@echo "Targets:"
1414
@echo " help Show this help message"
1515
@echo " For Parent VM:"
16-
@echo " setup-docker Install Docker (requires Ubuntu + sudo) for Parent VM"
17-
@echo " setup-nitro-cli Install Nitro Enclaves Driver and CLI for Parent VM"
16+
@echo " setup-docker Install Docker (requires Ubuntu + sudo)"
17+
@echo " setup-nitro-cli Install Nitro Enclaves Driver and CLI"
1818
@echo " build-enclave Build enclave Docker image and create EIF file"
1919
@echo " build-proxy Build vsock proxy"
2020
@echo " run-enclave Run Nitro Enclave"
2121
@echo " run-proxy Run vsock proxy"
2222
@echo " terminate-enclave Terminate Nitro Enclave"
2323
@echo " For Client:"
24-
@echo " setup-client Install Rust and AWS Nitro Enclaves root certificate"
24+
@echo " setup-client Install Rust and dependencies"
2525
@echo " build-client Build client application"
26+
@echo " download-root-ca Download AWS Nitro Enclaves root CA certificate"
2627
@echo " run-client Run client"
2728

2829
setup-docker:
@@ -37,6 +38,10 @@ setup-client:
3738
@echo "Running scripts/setup-client.sh"
3839
@bash ./scripts/setup-client.sh
3940

41+
download-root-ca:
42+
@echo "Running scripts/download-root-ca.sh"
43+
@bash ./scripts/download-root-ca.sh
44+
4045
build-enclave:
4146
@echo "Building Docker image"
4247
@docker build -t rafwne-enclave ./enclave

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,56 @@ This repository demonstrates a simple end-to-end flow against an AWS Nitro Encla
66
- **Parent VM**: An AWS EC2 instance (Ubuntu 24.04) with Nitro Enclaves enabled. Runs the Enclave and the vsock proxy.
77
- **Client**: Can run on any machine, but this README assumes you run it on the Parent VM (localhost).
88

9-
## Tested environment (detailed)
9+
## Tested environments
10+
11+
Tested on the Parent VM environments listed below. The Server (vsock proxy) runs on localhost on the Parent VM, and the Client also runs on the same Parent VM.
1012

1113
### Parent VM (AWS EC2)
1214

15+
#### Ubuntu 24.04 (x86_64)
16+
1317
- **Instance type**: `c5.xlarge`
1418
- vCPUs: 4
1519
- Memory: 8 GiB
16-
- CPU arch: `x86_64`
20+
- CPU arch: x86_64
1721
- **AMI**: Ubuntu Server 24.04 LTS
1822
- AMI ID: `ami-06e3c045d79fd65d9`
19-
- **Storage**: 64 GiB `gp3`
23+
- **Storage**: 64 GiB gp3
24+
- **Kernel**: 6.14.0-1018-aws
25+
- **Nitro Enclaves**: Enabled
26+
- **Nitro Enclaves CLI / driver**: v1.4.4
27+
28+
#### Ubuntu 24.04 (AArch64)
29+
30+
- **Instance type**: `m6g.xlarge`
31+
- vCPUs: 4
32+
- Memory: 16 GiB
33+
- CPU arch: AArch64
34+
- **AMI**: Ubuntu Server 24.04 LTS
35+
- AMI ID: `ami-01da1dbf9ea3a6ee6`
36+
- **Storage**: 64 GiB gp3
2037
- **Kernel**: 6.14.0-1018-aws
2138
- **Nitro Enclaves**: Enabled
2239
- **Nitro Enclaves CLI / driver**: v1.4.4
23-
- **Rust toolchain**: v1.90.0
2440

2541
### Enclave
2642

2743
- **OS**: Ubuntu 24.04
2844
- **Allocated vCPUs**: 2
2945
- **Allocated Memory**: 512 MiB
30-
- **OS**: Ubuntu 24.04
31-
- **Rust toolchain**: v1.90.0
3246

33-
### Client
47+
### Test configuration
3448

35-
- Ran on the same Parent VM (localhost).
49+
- **Server (vsock proxy)**: Runs on localhost (`127.0.0.1`) on the Parent VM
50+
- **Client**: Runs on the same Parent VM
3651

3752
## Architecture
3853

3954
- `enclave/`: Enclave application (listens on vsock `port=5000`)
4055
- `proxy/`: **untrusted** HTTP → vsock proxy (listens on HTTP `ip:port`, forwards to vsock `port=5000`)
4156
- `client/`: Client app (POSTs JSON to the proxy, verifies attestation, then calls the confidential computing API)
4257

43-
## Quick start (all on the Parent VM)
58+
## Quick start
4459

4560
Clone the repository:
4661

@@ -49,17 +64,18 @@ git clone <THIS_REPOSITORY>
4964
cd <THIS_REPOSITORY>
5065
```
5166

52-
### 1. Parent VM setup (Ubuntu 24.04)
67+
### 1. Parent VM setup
5368

5469
```bash
5570
make setup-docker
5671
make setup-nitro-cli
5772
```
5873

59-
### 2. Client setup (this README runs it on the Parent VM)
74+
### 2. Client setup
6075

6176
```bash
6277
make setup-client
78+
make download-root-ca
6379
```
6480

6581
### 3. Build the Enclave image and copy PCRs into `client-configs.json`

scripts/download-root-ca.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Download AWS Nitro Enclaves root certificate
6+
AWS_CA_ZIP_FILE="AWS_NitroEnclaves_Root-G1.zip"
7+
curl -fsSL https://aws-nitro-enclaves.amazonaws.com/"$AWS_CA_ZIP_FILE" -o "$AWS_CA_ZIP_FILE"
8+
9+
# Extract the first *.pem found inside the zip directly to ./root.pem
10+
CA_PEM_PATH="$(unzip -Z1 "$AWS_CA_ZIP_FILE" | grep -Ei '\.pem$' | head -n1)"
11+
if [ -z "$CA_PEM_PATH" ]; then
12+
echo "ERROR: no .pem file found inside $AWS_CA_ZIP_FILE" >&2
13+
unzip -Z1 "$AWS_CA_ZIP_FILE" >&2 || true
14+
exit 1
15+
fi
16+
unzip -p "$AWS_CA_ZIP_FILE" "$CA_PEM_PATH" > ./root.pem
17+
chmod +r ./root.pem
18+
rm -f "$AWS_CA_ZIP_FILE"

scripts/setup-client.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,4 @@ sudo apt-get install -y build-essential pkg-config libssl-dev git unzip
88

99
# Install Rust
1010
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
11-
source $HOME/.cargo/env
12-
13-
# Download AWS Nitro Enclaves root certificate
14-
curl https://aws-nitro-enclaves.amazonaws.com/AWS_NitroEnclaves_Root-G1.zip -o AWS_NitroEnclaves_Root-G1.zip
15-
unzip -o AWS_NitroEnclaves_Root-G1.zip -d .
16-
rm AWS_NitroEnclaves_Root-G1.zip
17-
18-
# Make a stable filename expected by the Rust client (`root.pem`).
19-
#./*.pem => root.pem
20-
ls -la ./root.pem || cp ./*.pem root.pem
11+
source "$HOME/.cargo/env"

scripts/setup-nitro-cli.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -e
44

5-
USERNAME="$(whoami)"
65
KERNEL_VERSION="$(uname -r)"
76

87
# Install dependencies
@@ -11,7 +10,7 @@ sudo apt-get install -y build-essential git clang libclang-dev llvm-dev linux-mo
1110

1211
# Install Rust
1312
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
14-
source $HOME/.cargo/env
13+
source "$HOME/.cargo/env"
1514

1615
# Install Nitro Enclaves driver and CLI
1716
git clone https://github.com/aws/aws-nitro-enclaves-cli -b v1.4.4
@@ -29,9 +28,12 @@ pushd aws-nitro-enclaves-cli
2928
sudo make nitro-cli
3029
sudo make vsock-proxy
3130
sudo make NITRO_CLI_INSTALL_DIR=/ install
32-
source ./build/install/etc/profile.d/nitro-cli-env.sh
33-
echo source ./build/install/etc/profile.d/nitro-cli-env.sh >> ~/.bashrc
34-
./build/install/etc/profile.d/nitro-cli-config -i
31+
source /etc/profile.d/nitro-cli-env.sh
32+
grep -qF 'source /etc/profile.d/nitro-cli-env.sh' "$HOME/.bashrc" \
33+
|| echo 'source /etc/profile.d/nitro-cli-env.sh' >> "$HOME/.bashrc"
34+
set +e
35+
( nitro-cli-config -i ) || echo "nitro-cli-config failed with exit code $?"
36+
set -e
3537
popd
3638

3739
# Start and enable the Nitro Enclaves Allocator Service

0 commit comments

Comments
 (0)