Skip to content

Commit

Permalink
add sgx_mode arg to docker builds; add sgx device to docker compose t…
Browse files Browse the repository at this point in the history
…ests; fix path of enclave code signing key; fix some xfer folder paths

Signed-off-by: Bruno Vavala <[email protected]>
  • Loading branch information
bvavala committed Mar 15, 2024
1 parent e91a785 commit 132ba81
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.
1 change: 1 addition & 0 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ rebuild : clean-build build $(CONDITIONAL_REGISTER_TARGET)
system-keys : ${PDO_ENCLAVE_CODE_SIGN_PEM}

${PDO_ENCLAVE_CODE_SIGN_PEM} :
mkdir -p ${PDO_HOME}/keys/sgx/
openssl genrsa -3 -out ${PDO_ENCLAVE_CODE_SIGN_PEM} 3072

# SERVICES_COUNT is the number of services of each type to create
Expand Down
18 changes: 16 additions & 2 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ DOCKER_DIR ?= ${PDO_SOURCE_ROOT}/docker
DOCKER_USERNAME = $(LOGNAME)
DOCKER_BUILDARGS += --build-arg UID=$(PDO_USER_UID)
DOCKER_BUILDARGS += --build-arg GID=$(PDO_GROUP_UID)
DOCKER_BUILDARGS += --build-arg SGX_MODE=$(SGX_MODE)
DOCKER_ARGS = $(DOCKER_BUILDARGS)

IMAGES=base client services_base services ccf_base ccf
Expand Down Expand Up @@ -127,11 +128,24 @@ TEST_FILES += -f services_base.yaml
TEST_FILES += -f ccf_base.yaml
TEST_FILES += -f test.yaml

DOCKER_COMPOSE_COMMAND=docker-compose

ifeq ($(SGX_MODE),HW)
TEST_FILES += -f test-sgx.yaml
SGX_DEVICE_PATH=$(shell if [ -e "/dev/isgx" ]; \
then echo "/dev/isgx"; \
elif [ -e "/dev/sgx/enclave" ]; \
then echo "/dev/sgx/enclave"; \
else echo "ERROR: NO SGX DEVICE FOUND"; \
fi)
DOCKER_COMPOSE_COMMAND := env SGX_MODE=$(SGX_MODE) SGX_DEVICE_PATH=${SGX_DEVICE_PATH} ${DOCKER_COMPOSE_COMMAND}
endif

build_test : repository build_services build_ccf build_client

test : clean_config clean_repository build_test stop_all
PDO_VERSION=$(PDO_VERSION) docker-compose $(TEST_FILES) up --abort-on-container-exit
PDO_VERSION=$(PDO_VERSION) docker-compose $(TEST_FILES) down
PDO_VERSION=$(PDO_VERSION) $(DOCKER_COMPOSE_COMMAND) $(TEST_FILES) up --abort-on-container-exit
PDO_VERSION=$(PDO_VERSION) $(DOCKER_COMPOSE_COMMAND) $(TEST_FILES) down

# -----------------------------------------------------------------
# Cleaning is a bit interesting because the containers don't go away
Expand Down
23 changes: 23 additions & 0 deletions docker/test-sgx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------------------
version: "3.4"

services:
services_container:
volumes:
- /var/run/aesmd:/var/run/aesmd
devices:
- ${SGX_DEVICE_PATH:-/dev/isgx}:${SGX_DEVICE_PATH:-/dev/isgx}

2 changes: 1 addition & 1 deletion docker/tools/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fi

# this variable is needed for the build for signing the
# eservice and pservice enclaves
export PDO_ENCLAVE_CODE_SIGN_PEM=${PDO_SGX_KEY_ROOT}/enclave_code_sign.pem
export PDO_ENCLAVE_CODE_SIGN_PEM=${PDO_HOME}/keys/sgx/enclave_code_sign.pem

# these are only used for configuration and registration
# they are not used at build or run time
Expand Down
2 changes: 1 addition & 1 deletion docker/tools/run_services_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ yell check for registration
# -----------------------------------------------------------------
# this probably requires additional CCF keys, need to test this
if [ "$SGX_MODE" == "HW" ]; then
if [ ! -f ${XFER}/ccf/keys/memberccf_privk.pem ] ; then
if [ ! -f ${XFER_DIR}/ccf/keys/memberccf_privk.pem ] ; then
die unable to locate CCF policies keys
fi

Expand Down
2 changes: 1 addition & 1 deletion docker/tools/start_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ try cp ${XFER_DIR}/ccf/keys/networkcert.pem ${PDO_LEDGER_KEY_ROOT}/
yell register the enclave if necessary
# -----------------------------------------------------------------
if [ "${F_REGISTER,,}" == 'yes' ]; then
if [ ! -f ${XFER}/ccf/keys/memberccf_privk.pem ] ; then
if [ ! -f ${XFER_DIR}/ccf/keys/memberccf_privk.pem ] ; then
die unable to locate CCF policies keys
fi

Expand Down

0 comments on commit 132ba81

Please sign in to comment.