Privasys
SolutionsEnclave osEnclave os miniGuides

Deploy Enclave OS

Build and deploy Enclave OS (Mini) on SGX hardware: prerequisites, building, provisioning, and running.

If you want a managed deployment experience instead, the Developer Platform handles hardware allocation, builds, and attestation for you. See Getting Started.

This guide walks you through building Enclave OS from source and deploying it on Intel SGX hardware.

Repository: github.com/Privasys/enclave-os-mini

Prerequisites

Host machine (build + run)

DependencyPurposeInstall
Rust nightly-2025-12-01Enclave compilationrustup install nightly-2025-12-01
rust-src componentSGX sysroot buildrustup component add rust-src --toolchain nightly-2025-12-01
Intel SGX SDK 2.25sgx_edger8r, sgx_sign, runtime libsIntel SGX SDK
Intel SGX PSWAESM service (quoting)apt install sgx-aesm-service libsgx-dcap-ql
CMake 3.20+Build systemapt install cmake
GCC / build-essentialC compiler (EDL glue, RocksDB)apt install build-essential
pkg-configLibrary discoveryapt install pkg-config

WASM development (optional)

DependencyPurposeInstall
Rust stable 1.82+WASM app compilationrustup update stable
wasm32-wasip2 targetWASI Component Modelrustup target add wasm32-wasip2
cargo-componentWIT-based WASM buildscargo install cargo-component
Wasmtime CLIAOT pre-compilationcargo install wasmtime-cli

Building the Enclave

Standard build (no WASM)

git clone https://github.com/Privasys/enclave-os-mini.git
cd enclave-os-mini

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)

Outputs in build/bin/:

  • enclave-os-host: untrusted host binary
  • enclave.signed.so: signed SGX enclave

Build with WASM runtime

The WASM runtime requires a composition crate that combines the base enclave with the WASM module. The wasm-app-example repository provides one:

# Clone the composition crate
git clone https://github.com/Privasys/wasm-app-example.git

# Build enclave-os-mini with WASM enabled
cd enclave-os-mini
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
    -DENABLE_WASM=ON \
    -DWASM_ENCLAVE_DIR=/path/to/wasm-app-example/enclave
cmake --build build -j$(nproc)

The -DWASM_ENCLAVE_DIR flag is required when -DENABLE_WASM=ON; it points CMake at the composition crate that registers the WASM module.

Build options

CMake flagDefaultDescription
CMAKE_BUILD_TYPEDebugRelease for production (LTO, no debug symbols)
ENABLE_WASMOFFEnable the WASM runtime module
WASM_ENCLAVE_DIR(none)Path to the WASM composition crate (required when ENABLE_WASM=ON)

Host-only build (development on Windows/macOS)

For local development without SGX hardware, build only the host crate in mock mode:

cargo build --manifest-path host/Cargo.toml

Running tests

cargo test --workspace

Running the Enclave

First run: provision CA material

On the first run, provide the intermediary CA certificate and private key so the enclave can seal them:

cd build/bin

./enclave-os-host \
    --port 8443 \
    --kv-path ./kvdata \
    --ca-cert /path/to/intermediary-ca.crt \
    --ca-key  /path/to/intermediary-ca.key \
    --egress-ca-bundle /etc/ssl/certs/ca-certificates.crt \
    --debug
FlagRequiredDescription
--portyesTLS listen port
--kv-pathyesDirectory for RocksDB encrypted KV store
--ca-certfirst runPEM or DER intermediary CA certificate
--ca-keyfirst runPEM or PKCS#8 CA private key (ECDSA P-256)
--egress-ca-bundleoptionalRoot CA bundle for HTTPS egress
--debugoptionalEnable debug logging

The enclave will:

  1. Generate an AES-256 master key via RDRAND
  2. Seal everything into a unified SealedConfig (MRENCLAVE policy)
  3. Store the sealed blob in the KV store
  4. Start the RA-TLS server

Subsequent restarts

The enclave automatically unseals the config, so no flags are needed beyond port and KV path:

./enclave-os-host \
    --port 8443 \
    --kv-path ./kvdata

Providing --ca-cert or --ca-key on restart updates the sealed config (e.g. CA rotation). The master key is preserved.

Production deployment

For production, run the enclave behind a Layer 4 (TCP passthrough) proxy. The enclave terminates TLS internally, so the proxy must NOT terminate TLS.

See the Layer 4 Proxy Guide for Caddy (caddy-l4) and HAProxy configurations.

Loading WASM Apps

The enclave starts empty; no WASM apps are compiled in. Apps are loaded at runtime over the RA-TLS connection. See Build a WASM App for the full workflow.

Quick start

# 1. Build the WASM app
cd wasm-app-example
cargo component build --release

# 2. Pre-compile to .cwasm
wasmtime compile target/wasm32-wasip1/release/wasm_example.wasm -o wasm_example.cwasm

# 3. Load into the enclave
python tests/test_wasm_functions.py wasm_example.cwasm

Client Libraries

Use RA-TLS clients to connect to the enclave with verification:

LanguagePackage
Pythonra-tls-verify
Goratls
Rustra-tls-verify
TypeScript@privasys/ra-tls
C#Privasys.RaTls

Verifying the RA-TLS certificate

# View certificate extensions
openssl s_client -connect enclave.example.com:443 </dev/null 2>&1 | \
    openssl x509 -text -noout | grep -A2 "1.3.6.1.4.1.65230"

Expected OIDs:

  • 1.3.6.1.4.1.65230.1.1: Config Merkle Root
  • 1.3.6.1.4.1.65230.2.1: Egress CA Hash
  • 1.3.6.1.4.1.65230.2.3: WASM Apps Hash
Edit on GitHub