Using Fortanix Confidential Computing Manager to Build an Enclave OS Application from Scratch

1.0 Introduction

This guide will walk you through creating a simple dockerized python server and then deploy it within a Trusted Execution Environment using Fortanix Enclave OS. The guide offers the options to convert your docker application to an Enclave OS application either using the Fortanix CCM UI or by issuing REST API calls.

2.0 Create a Docker Application

2.1 Creating a Python Application

Let us start by creating a simple Python server using Flask. Create a file named with the following contents:

from flask import Flask
app = Flask("Hello Flask Server")

def hello():
return "Hello Flask"

if __name__ == '__main__':'', port='9000')

This application is a minimal Flask server that accepts requests on port 9000 and returns a greeting message.

2.2 Create a Docker Container

Next, let us create a docker container containing this application and push it to a container registry.

Step 1: Create a dockerfile

Create a file called dockerfile with the following contents:

FROM python:3.7

RUN pip3 install flask

RUN mkdir /app
COPY /app/

ENTRYPOINT ["python3", ""]

Step 2: Build a docker image

You can now create a docker image by running the following command:

docker build -t fortanix/python-flask:latest .
If you want to use your own container registry, replace "fortanix" with the name of your registry.

You can now run the docker container using the following command:

docker run -p 9000:9000 fortanix/python-flask:latest

From another terminal, you can use the following command to send an HTTP request to your newly deployed server:

curl localhost:9000

Step 3: Push the image to a registry

To make this image publicly accessible, you can push it to a public registry as follows:

docker push fortanix/python-flask:latest
The above command will fail if you have not used your own registry, but you can skip this step since the image is already pushed and available in the Fortanix public registry.

3.0 Option 1: Build an Enclave OS Application Using the Fortanix CCM UI

In this section of the guide, we will walk through the steps of converting your docker application into an Enclave OS application, that can run securely inside a Trusted Execution Environment, using the Fortanix CCM UI.

3.1 Signing in to the Fortanix CCM UI

Go to and use your email address and password to log in.

CCM_5.png Figure 2: Log In Page

3.2 Select an Account

To select an account, click the SELECT ACCOUNT button.

Figure 2: Select an Account

3.3 Create a Group

  1. Navigate to the Groups menu item from the CCM UI left navigation bar and click + ADD GROUP to add a group.
    Figure 3: Add Group Button
  2. Click the ADD GROUP button to create a new group.
  3. Enter the required Name for the group and add Labels with Key:Value pairs.
  4. Click the CREATE GROUP button.

The group is successfully created.

3.4 Create an Application

To create an application using Fortanix CCM UI, navigate to the Applications menu item in the CCM UI left navigation bar and click + APPLICATION to create a new application.

Figure 4: Create an Application

Now, in the Add application form, add the details of the application.

add-application-1.png add-application-2.png

Figure 5: Configure an Application

3.5 Create an Image

In the detailed view of the application, click +IMAGES to create an image.

image-1.pngFigure 6: Create an Image

Enter the REGISTRY CREDENTIALS for the Output image name. Registry Credentials are the credentials to access the private docker registry where the image will be pushed. The Input image does not require credentials since it is a public registry. Also, provide the image tag. Click CREATE to proceed.

image-3.pngFigure 7: Create an Image

3.6 Approve Application Build

From the CCM UI left navigation bar, select the Tasks menu item. On the Tasks page, to approve the application build, click on the task and then click APPROVE.

Figure 8: View and Approve the Application Build

4.0 Option 2: Build an Enclave OS Application Using REST API Calls

In this section of the guide, we will walk through the steps of converting your docker application into an Enclave OS application, that can run securely inside a Trusted Execution Environment, using the Fortanix CCM REST API.

4.1 Authenticate to Fortanix CCM

Before you can issue any requests, you first need to authenticate to Fortanix CCM using the following commands:

cpath=$(mktemp -p "/tmp" -t "fortanix_ccm_cookie.XXXXX")
curl -u <username>:<password> -c $cpath -X POST

where <username> and <password> need to be replaced with the email address and password of your Fortanix CCM account.

Authentication session tokens are short-lived. If you ever get the response {"message":"Forbidden","code":"FORBIDDEN"} you can run the following command to refresh the session token.
curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -X POST

4.2 Select an Account Using an API Call

Once you have successfully authenticated to Fortanix CCM, you need to select an account. First, you can list all accounts available using the following command:

curl -b $cpath -c $cpath -H "X-CSRF-Header:true"

This command will return a JSON string of the following form:

{"name":"My account","acct_id":"26eaa328-5eb4-41c7-b09b-8a3e0a0f65c7", ...}, ...

To select an account you need to copy the account id of the account you are interested in (the string 26eaa328-5eb4-41c7-b09b-8a3e0a0f65c7 in the example above), let us call it <account_id>, and run:

curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -X POST<account_id>

4.3 Create an Application Using an API Call

Next, to create a new application, create a file called app.json whose contents are shown below. Make sure to replace the output_image_name with your private registry.

"name":"Python Flask Server",

Then, create an application using the following API call:

curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -H "Content-Type: application/json" -d @app.json -X POST

This will print information about the newly created application including its <app_id>:

{"name":"Python Flask Server","app_id":"cc386097-dcf7-4813-880a-ddacdafb48a2",...}

4.4 Create an Image Using an API Call

Once the application has been created, you can similarly create an image by following these steps. First, create a file called build.json as shown below. Replace <app_id> with the ID of your newly created application. The <username> and <password> are the credentials of the registry that you want the converted image to be stored at. This was specified above as output_image_name.

See the Fortanix CCM Quickstart guide on how to set up registry credentials to avoid including credentials in this file.

Now you can create the image using the following command:

curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -H "Content-Type: application/json" -d @build.json -X POST

This returns the output that shows the <task_id> (f0d815b6-9520-4ce4-b4f4-6a82a718bb7e in this example), among other information:


Finally, you can approve the image using its <task_id> and the following command:

curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -H "Content-Type: application/json" -d '{"status":"APPROVED"}' -X PATCH<task_id>

5.0 Run the Application

Whether you chose to create your application using the UI or the API option, you should now have converted and whitelisted an application image and can run the application on an SGX compute node.

Run the application using the following commands:

docker run --privileged --volume /dev:/dev -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket -e NODE_AGENT_BASE_URL= fortanix-private/python-flask-sgx:latest


  • 9092 is the default port on which Node Agent listens to.
  • is the IP address of your compute node.
  • fortanix-private/python-flask-sgx:latest is the converted app.
  • Use your own inputs for Node IP, Port, and Converted Image in the above format. The information in the example above is just a sample.
  • Add the following flag along with the command to get more details:
    • -e ENCLAVEOS_LOG_LEVEL=debug - to get debug log
    • -p 7622:80 -p 8038:443 - to map the application custom port to 80 or 443


Please sign in to leave a comment.

Was this article helpful?
0 out of 0 found this helpful