README.md 3.2 KB
Newer Older
1 2 3 4 5 6 7
# Before you start
- Refer to [this guide](https://github.com/alibaba/inclavare-containers#rune) to build `rune` from scratch.
- Register a `SPID` and `Subscription Key` of [IAS](https://api.portal.trustedservices.intel.com/EPID-attestation). After the registration, Intel will respond with a SPID which is needed to communicate with IAS.

# Run stub with Docker
## Configure SGX RA settings
```shell
jia zhang's avatar
jia zhang 已提交
8 9 10 11 12
export SPID=<hex string>
export EPID_SUBSCRIPTION_KEY=<hex string>
export QUOTE_TYPE=<SGX_LINKABLE_SIGNATURE | SGX_UNLINKABLE_SIGNATURE>
```

13 14 15
## Install dependency
```shell
yum install -y patch autoconf automake libtool
16 17
```

18 19 20 21 22
## Build liberpal-stub
```shell
cd "${path_to_inclavare_containers}/ra-tls"
make
cp pal/liberpal-stub.so /usr/lib
23 24
```

25 26 27 28
# Build stub container image
```shell
cd "${path_to_inclavare_containers}/ra-tls/stub-enclave"
cat >Dockerfile <<EOF
29 30
FROM ubuntu:18.04
  
jia zhang's avatar
jia zhang 已提交
31
RUN mkdir -p /run/rune/stub-enclave
32 33
WORKDIR /run/rune

jia zhang's avatar
jia zhang 已提交
34
COPY Wolfssl_Enclave.signed.so  stub-enclave
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
EOF
docker build -t stub-enclave .
```

# Run stub container image with rune
## Configure OCI runtime
Refer to [this guide](https://github.com/alibaba/inclavare-containers/blob/master/rune/libenclave/internal/runtime/pal/skeleton/README.md#configure-oci-runtime) to configure OCI runtime in dockerd config file.

## Run stub container image with rune
```shell
docker run -it --rm --runtime=rune -e ENCLAVE_TYPE=intelSgx \
	-e ENCLAVE_RUNTIME_PATH=/usr/lib/liberpal-stub.so \
	-e ENCLAVE_RUNTIME_ARGS=stub-enclave stub-enclave
```

# Run stub OCI bundle
## Create stub bundle
In order to use `rune` you must have your container image in the format of an OCI bundle. If you have Docker installed you can use its `export` method to acquire a root filesystem from an existing stub-enclave Docker container image.
53

54 55 56 57 58 59 60 61 62 63 64
```shell
# create the top most bundle directory
cd "$HOME/rune_workdir"
mkdir rune-container
cd rune-container

# create the rootfs directory
mkdir rootfs

# export stub-enclave image via Docker into the rootfs directory
docker export $(docker create stub-enclave) | sudo tar -C rootfs -xvf -
65 66
```

67 68 69 70
After a root filesystem is populated you just generate a spec in the format of a config.json file inside your bundle. `rune` provides a spec command which is similar to `runc` to generate a template file that you are then able to edit.

```shell
rune spec
71 72
```

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
To find features and documentation for fields in the spec please refer to the [specs](https://github.com/opencontainers/runtime-spec) repository.

In order to run the stub-enclave bundle with `rune`, you need to configure enclave runtime as following:
```json
  "annotations": {
      "enclave.type": "intelSgx",
      "enclave.runtime.path": "/usr/lib/liberpal-stub.so",
      "enclave.runtime.args": "stub-enclave"
  }
```

where:
- @enclave.type: specify the type of enclave hardware to use, such as intelSgx.
- @enclave.runtime.path: specify the path to enclave runtime to launch.
- @enclave.runtime.args: specify the specific arguments to enclave runtime, seperated by the comma.

## Run stub
Assuming you have an OCI bundle from the previous step you can execute the container in this way.

```shell
cd "$HOME/rune_workdir/rune-container"
sudo rune run stub-enclave-container
95
```