Skip to content

Commit 4aa499e

Browse files
authored
Add clearer docs for how to build/sign application (#560)
1 parent ae9a416 commit 4aa499e

File tree

10 files changed

+74
-46
lines changed

10 files changed

+74
-46
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ target_link_libraries(logging_client PRIVATE
3333
${CMAKE_THREAD_LIBS_INIT}
3434
)
3535

36-
# SNIPPET: Logging application
3736
add_enclave_lib(loggingenc ${CMAKE_CURRENT_SOURCE_DIR}/src/apps/logging/oe_sign.conf ${CMAKE_CURRENT_SOURCE_DIR}/src/apps/sample_key.pem SRCS src/apps/logging/logging.cpp src/apps/logging/stub_for_code_signing.cpp)
3837

3938
if(BUILD_TESTS)

cmake/common.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ set(CCF_NETWORK_TEST_ARGS
571571
${PBFT_ARG}
572572
)
573573

574-
# Lua generic app
574+
# SNIPPET: Lua generic application
575575
add_enclave_lib(luagenericenc ${CCF_DIR}/src/apps/luageneric/oe_sign.conf ${CCF_DIR}/src/apps/sample_key.pem SRCS ${CCF_DIR}/src/apps/luageneric/luageneric.cpp)
576576

577577
# Samples
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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.

sphinx/source/developers/example.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Example App
2-
===========
1+
Example Application
2+
===================
33

44
Description
55
-----------
@@ -74,6 +74,7 @@ The Logging application implements a trivial protocol, made up of four transacti
7474
}
7575
}
7676
77+
7778
Implementations
7879
---------------
7980

sphinx/source/developers/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Writing CCF Applications
33

44
This section describes how CCF applications can be developed and deployed to a CCF network.
55

6-
Applications can be written in C++ or Lua (see :ref:`Example App`). An application consists of a collection of endpoints that can be triggered by :term:`users` using JSON-RPC. Each endpoint can define an :ref:`API Schema` to validate user requests.
6+
Applications can be written in C++ or Lua (see :ref:`Example Application`). An application consists of a collection of endpoints that can be triggered by :term:`users` using JSON-RPC. Each endpoint can define an :ref:`API Schema` to validate user requests.
77

88
These endpoints mutate the state of a unique :ref:`Key-Value Store` that represents the internal state of the application. Applications define a set of ``Maps`` (see :ref:`Creating a Map`), mapping from a key to a value. When an application endpoint is triggered, the effects on the Store are committed atomically.
99

@@ -14,6 +14,7 @@ These endpoints mutate the state of a unique :ref:`Key-Value Store` that represe
1414
:caption: Contents:
1515

1616
example
17+
build_app
1718
demo
1819
kv/index.rst
1920
ledger

sphinx/source/developers/logging_cpp.rst

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -113,30 +113,6 @@ This produces validation error messages with a lower performance overhead, and e
113113

114114
Both approaches register their RPC's params and result schema, allowing them to be retrieved at runtime with calls to the getSchema RPC.
115115

116-
Build
117-
-----
118-
119-
Once an application is complete, it needs to be built into a shared object, and signed:
120-
121-
.. literalinclude:: ../../../CMakeLists.txt
122-
:language: cmake
123-
:start-after: SNIPPET: Logging application
124-
:lines: 1
125-
126-
For signing to work, a configuration is necessary. The configuration should be called `oe_sign.conf`, and
127-
be placed under the same directory as the source files for the application.
128-
129-
.. literalinclude:: ../../../src/apps/logging/oe_sign.conf
130-
131-
Running
132-
-------
133-
134-
This produces the enclave library ``libloggingenc.so.signed`` which can be loaded by the cchost application:
135-
136-
.. code-block:: bash
137-
138-
$ cchost --enclave-file libloggingenc.so.signed [args]
139-
140116
.. rubric:: Footnotes
141117

142118
.. [#valijson] `Valijson is a header-only JSON Schema Validation library for C++11 <https://github.com/tristanpenman/valijson>`_.

sphinx/source/developers/logging_lua.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,3 @@ The tables passed to a Lua handler in ``tables`` and ``gov_tables`` can be acces
7070

7171
* ``end_order()``: returns the "commit version" of the table. (Probably not useful for most applications.)
7272

73-
74-
Running
75-
-------
76-
77-
:ref:`Operators should start the first CCF node <Starting the First Node>` with `luageneric` as enclave file:
78-
79-
.. code-block:: bash
80-
81-
cchost --enclave-file libluageneric.signed.so [args]
82-
83-
Then, members should :ref:`register the Lua application <Registering the Lua Application>`.
84-
85-

sphinx/source/members/open_network.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The user is successfully added once a :term:`quorum` of members have accepted th
3030
Registering the Lua Application
3131
-------------------------------
3232

33-
.. note:: This section only applies when deploying Lua applications (i.e. using the ``libluageneric.so.signed`` enclave library). For C++ applications, this step should be skipped.
33+
.. note:: This section only applies when deploying Lua applications (i.e. using the ``libluagenericenc.so.signed`` enclave library). For C++ applications, this step should be skipped.
3434

3535
Before opening the CCF network to users, members should vote to register the Lua application defining the user-specific business logic (see for example :ref:`Logging (Lua)`):
3636

@@ -71,4 +71,4 @@ Other members are then allowed to vote for the proposal, using the proposal id r
7171
$ memberclient --cert member3_cert --privk member3_privk --rpc-address rpc_ip:rpc_port --ca network_cert vote --proposal-id 2 --accept
7272
{"commit":19,"global_commit":18,"id":0,"jsonrpc":"2.0","result":true,"term":2}
7373
74-
Once a quorum of members have approved the network opening (``"result":true``), the network is opened to users (see :ref:`Example App` for a simple business logic and :term:`JSON-RPC` transactions). It is only then that users are able to execute transactions on the business logic defined by the enclave file (``--enclave-file`` option to ``cchost``).
74+
Once a quorum of members have approved the network opening (``"result":true``), the network is opened to users (see :ref:`Example Application` for a simple business logic and :term:`JSON-RPC` transactions). It is only then that users are able to execute transactions on the business logic defined by the enclave file (``--enclave-file`` option to ``cchost``).

sphinx/source/quickstart/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Once this is done, you can quickly spin up a CCF network and start :ref:`issuing
2323
You should also get familiar with some of :ref:`CCF concepts`. You will then be able to:
2424

2525
1. :ref:`Create a consortium and agree on the constitution <Member Governance>`
26-
2. :ref:`Develop a CCF application, based on the example logging application <Example App>`
26+
2. :ref:`Develop a CCF application, based on the example logging application <Example Application>`
2727
3. :ref:`Start a new CCF network to deploy the application <Starting a New Network>`
2828
4. :ref:`Let the consortium configure and open the network to users <Opening a Network>`
2929
5. :ref:`Have users issue business transactions to the application <Using CCF Applications>`

sphinx/source/users/issue_commands.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Issuing Commands
33

44
Clients communicate with CCF using framed :term:`JSON-RPC` over :term:`TLS`. The ``method`` must be prefixed with the name of the target frontend (``"users"`` or ``"members"``), separated from the intended ``method`` with a single ``/``.
55

6-
Users can issue business transactions to CCF using the ``client`` command-line utility built with CCF. For example, to record a message at a specific id with the :ref:`Example App`:
6+
Users can issue business transactions to CCF using the ``client`` command-line utility built with CCF. For example, to record a message at a specific id with the :ref:`Example Application`:
77

88
.. code-block:: bash
99

0 commit comments

Comments
 (0)