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


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.

Create a Docker Application

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.

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.

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.

Signing in to the Fortanix CCM UI

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


Select an Account

To select an account, click the SELECT ACCOUNT button.

Figure 2: Select an account

Create an Application

To create an application using Fortanix CCM UI, navigate to the Applications tab and click + APPLICATION to create a new application.

Figure 3: Create an application

To create an application, select Applications from the navigation menu on the left, click +APPLICATION and add the details of the application.

CCMAppNew1a.pngQuickstart4a.png                                                      Figure 4: Configure an application

Create an Image

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

Figure 5: 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.

Figure 6: Create an image

Approve Application Build

From the navigation menu select Tasks. To approve the application build, click on the task and then click APPROVE.

Figure 7: View and approve the application build

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.

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

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>

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",...}

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>

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.
  • Please 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