|
| 1 | +Build and Sign Application |
| 2 | +========================== |
| 3 | + |
| 4 | +Once an application is complete, it needs to be built into a shared object, and signed. |
| 5 | + |
| 6 | +Using `cmake`, an application can be built and automatically signed using the ``add_enclave_lib`` function, provided by CCF's ``CCF/cmake/common.cmake``. For example, for the ``luageneric`` application: |
| 7 | + |
| 8 | +.. literalinclude:: ../../../cmake/common.cmake |
| 9 | + :language: cmake |
| 10 | + :start-after: SNIPPET: Lua generic application |
| 11 | + :lines: 1 |
| 12 | + |
| 13 | +The :term:`Open Enclave` configuration file (``oe_sign.conf``) should be placed under the same directory as the source files for the application. For example: |
| 14 | + |
| 15 | +.. literalinclude:: ../../../src/apps/logging/oe_sign.conf |
| 16 | + |
| 17 | +.. note:: The `Open Enclave documentation <https://github.com/openenclave/openenclave/blob/master/docs/GettingStartedDocs/buildandsign.md#signing-the-enclave>`_ provides details about the enclave settings in the ``oe_sign.conf`` configuration file. |
| 18 | + |
| 19 | +Standalone Signing |
| 20 | +------------------ |
| 21 | + |
| 22 | +It is also possible to sign an existing enclave application (e.g. ``libluagenericenc.so``) manually, using a personal signing key (specified by ``--key-file``): |
| 23 | + |
| 24 | +.. code-block:: bash |
| 25 | +
|
| 26 | + $ /opt/openenclave/bin/oesign sign --enclave-image libluagenericenc.so --config-file CCF/src/apps/luageneric/oe_sign.conf --key-file CCF/src/apps/sample_key.pem |
| 27 | + Created libluagenericenc.so.signed |
| 28 | + $ ls *.so.signed |
| 29 | + libluagenericenc.so.signed |
| 30 | +
|
| 31 | +It is then possible to inspect the signed enclave library: |
| 32 | + |
| 33 | +.. code-block:: bash |
| 34 | +
|
| 35 | + $ /opt/openenclave/bin/oesign dump --enclave-image libluagenericenc.so.signed |
| 36 | + === Entry point: |
| 37 | + name=_start |
| 38 | + address=00000000008dee48 |
| 39 | +
|
| 40 | + === SGX Enclave Properties: |
| 41 | + product_id=1 |
| 42 | + security_version=1 |
| 43 | + debug=1 |
| 44 | + xfrm=0 |
| 45 | + num_heap_pages=32768 |
| 46 | + num_stack_pages=1024 |
| 47 | + num_tcs=8 |
| 48 | + mrenclave=3175971c02d00c1a8f9dd23ca89e64955c5caa94e24f4a3a0579dcfb2e6aebf9 |
| 49 | + signature=... |
| 50 | +
|
| 51 | +For a given application, the ``signature`` field depends on the key used to sign the enclave. See :ref:`Updating Code Version` for instructions on how members can register new application versions (``mrenclave`` field). |
| 52 | + |
| 53 | +.. note:: The `Open Enclave documentation <https://github.com/openenclave/openenclave/blob/master/docs/GettingStartedDocs/buildandsign.md#signing-the-enclave>`_. provides further details about how to sign enclave applications using ``oesign``. |
| 54 | + |
| 55 | +Running the Application |
| 56 | +----------------------- |
| 57 | + |
| 58 | +:ref:`Operators should start each CCF node <Starting the First Node>` with the signed enclave application as enclave file. For example, for the ``luageneric`` application: |
| 59 | + |
| 60 | +.. code-block:: bash |
| 61 | +
|
| 62 | + $ cchost --enclave-file libluagenericenc.signed.so [args] |
| 63 | +
|
| 64 | +.. note:: When deploying the ``luageneric`` application, members should also :ref:`register the Lua application <Registering the Lua Application>` before the network is opened to users. |
0 commit comments