Skip to content

Mono and C# Support

SCONE supports the mono platform, i.e., the cross platform, open source .NET framework. Hence, SCONE now also supports C#.


Ensure that you have the newest mono image and determine you SGX device:

docker pull sconecuratedimages/mono
docker run $MOUNT_SGXDEVICE -it sconecuratedimages/mono

In case you do not have an SGX driver installed, no device will be mounted and applications will run in SIM mode.


Let's try to compile a simple program:

cat > hello.cs <<EOF
using System;

public class HelloWorld
    public static void Main(string[] args)
        Console.WriteLine ("Hello Mono World");

We compile the program with csc inside the container:

csc hello.cs

Note that his compilation already happens inside of SGX enclaves.

Let's execute the binary and switch on debug outputs:

mono hello.exe

The output will look like:

Hello Mono World

Debug Output

You can show the configuration of SCONE by setting SCONE_VERSION=1, i.e., if you execute

SCONE_VERSION=1 mono hello.exe

the output will look like this:

export SCONE_SLOTS=256
export SCONE_MMAP32BIT=0
export SCONE_SSPINS=100
export SCONE_SSLEEP=4000
export SCONE_LOG=3
export SCONE_HEAP=1073741824
export SCONE_STACK=2097152
export SCONE_CONFIG=/etc/sgx-musl.conf
export SCONE_ESPINS=10000
export SCONE_MODE=sim
export SCONE_ALLOW_DLOPEN=yes (unprotected)
musl version: 1.1.24
Revision: 6da648645ce29121d24c40c9c18404cc43194f80 (Fri May 29 20:56:17 2020 +0000)
Branch: master

Enclave hash: fa29f3914117757bbd4e091f90c357ae92b4c4b6b9bfa80b21c32e66fe60ee26
Hello Mono World