examples: Extend example with basic trust schema (validator-config)
Change-Id: Iaf9f4abd57563e52cb167b55ba3b27d8ecc1ecd7
diff --git a/examples/README.md b/examples/README.md
index 22b71ac..f1f829c 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,22 +1,22 @@
-ndn-cxx examples
-================
+# ndn-cxx examples
-By default, examples in `examples/` folder are not built. To enable them, use
+By default, the examples in `examples/` folder are not built. To enable them, use
`--with-examples` configure option. For example:
./waf configure --with-examples
./waf
-There are two ways to add new examples, depending on their complexity:
+There are two ways to add new examples, depending on their complexity.
-1. Examples with a single translation unit
+1. **Examples with a single translation unit**
- For simple examples that have a single translation unit, the `.cpp` file can be directly put
- in `examples/` folder and it will be automatically compiled on the next run of `./waf`. Name
- of the compiled binary will be determined by the base name of the `.cpp` file. For example,
- `examples/foo.cpp` will be compiled into binary `foo` in `<build>/examples` folder:
+ For simple examples that have a single translation unit, the `.cpp` file can be directly put
+ in the `examples/` folder and it will be automatically compiled on the next run of `./waf`.
+ The name of the compiled executable will be determined by the base name of the `.cpp` file.
+ For instance, `examples/foo.cpp` will be compiled into an executable named `foo` inside the
+ `build/examples` folder:
- echo "int main() { return 0; }" > examples/foo.cpp
+ echo 'int main() { return 0; }' > examples/foo.cpp
./waf
# ... Compiling examples/foo.cpp
# ... Linking build/examples/foo
@@ -24,25 +24,23 @@
# To run the example
./build/examples/foo
-2. Examples with multiple translation units
+2. **Examples with multiple translation units**
- For more complex examples that contain multiple translation units, one can use
- the following directory structure:
+ For more complex examples that contain multiple translation units, one can use
+ the following directory structure:
- - Create a directory under `examples/` folder (e.g., `examples/bar`).
- The name of this directory will determine the name of the compiled binary
- (`<build>/examples/bar/bar`)
+ - Create a directory under the `examples/` folder (e.g., `examples/bar`). The name of this
+ directory will determine the name of the compiled executable (`build/examples/bar/bar`).
+ - Place any number of translation units (e.g., `examples/bar/a.cpp`, `examples/bar/b.cpp`,
+ ...) in this directory. All `.cpp` files in this directory will be compiled and linked
+ together to produce the binary executable of the example. One of the .cpp files must
+ contain the `main()` function.
- - Place any number of translation units (e.g., `examples/bar/a.cpp`, `examples/bar/b.cpp`,
- ...) in this directory. All `.cpp` files in this directory will be compiled and linked
- together to produce the binary of the example. One of the .cpp files should contain
- the `main()` function.
-
- For example:
+ For example:
mkdir examples/bar
- echo "int bar(); int main() { return bar(); }" > examples/bar/a.cpp
- echo "int bar() { return 10; } " > examples/bar/b.cpp
+ echo 'int bar(); int main() { return bar(); }' > examples/bar/a.cpp
+ echo 'int bar() { return 10; }' > examples/bar/b.cpp
./waf
# ... Compiling examples/bar/a.cpp
# ... Compiling examples/bar/b.cpp
@@ -50,3 +48,18 @@
# To run the example
./build/examples/bar/bar
+
+## Security configuration for example apps
+
+In order for the ``consumer`` example app to be able to properly authenticate data packets
+created by the ``producer`` app, you must configure the following parameters.
+
+1. Generate example trust anchor:
+
+ ndnsec key-gen /example
+ ndnsec cert-dump -i /example > example-trust-anchor.cert
+
+2. Create a key for the producer and sign it with the example trust anchor:
+
+ ndnsec key-gen /example/testApp
+ ndnsec sign-req /example/testApp | ndnsec cert-gen -s /example -i example | ndnsec cert-install -