Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 2c6732b

Browse files
committed
Add documentation
1 parent 9365564 commit 2c6732b

7 files changed

Lines changed: 161 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ Documentation for Snap will be kept in this repository for now with an emphasis
298298
* [plugin life cycle](docs/PLUGIN_LIFECYCLE.md)
299299
* [plugin signing](docs/PLUGIN_SIGNING.md)
300300
* [tribe](docs/TRIBE.md)
301+
* [secure plugin communication](docs/SECURE_PLUGIN_COMMUNICATION.md)
301302

302303
To learn more about Snap and how others are using it, check out our [blog](https://medium.com/intel-sdi). A good first post to read is [My How-to for the Snap Telemetry Framework](https://medium.com/intel-sdi/my-how-to-for-the-snap-telemetry-framework-e3bb641bc740#.6f5nk543t) by @mjbrender.
303304

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<!--
2+
http://www.apache.org/licenses/LICENSE-2.0.txt
3+
4+
5+
Copyright 2017 Intel Corporation
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
-->
19+
20+
# Secure Plugin Communication
21+
22+
Snap communicates with plugins over gRPC protocol, which in general transfers data in plaintext.
23+
Snap allows securing communication with plugins by opening TLS channels and using certificates to authenticate plugins and framework.
24+
25+
## Usage
26+
27+
This walkthrough assumes you have downloaded a Snap release as described in [Getting Started](../README.md#getting-started).
28+
29+
### Shortest guide
30+
31+
Assuming all the test files are available, the following steps will result in secure plugin communication:
32+
33+
```
34+
snapteld --log-level 1 --plugin-trust 0 --tls-cert /tmp/snaptest-cli.crt --tls-key /tmp/snaptest-cli.key --ca-cert-paths /tmp/snaptest-ca.crt
35+
## (in another terminal)
36+
## Load each plugin
37+
snaptel plugin load --plugin-cert /tmp/snaptest-srv.crt --plugin-key /tmp/snaptest-srv.key --plugin-ca-certs /tmp/snaptest-ca.crt plugins/snap-plugin-collector-rand
38+
## Start a sample task
39+
snaptel task create -t sample-task.json
40+
```
41+
42+
### Detailed preparation
43+
44+
Starting secure communication requires following steps:
45+
1. Obtain TLS certificate and private key for framework.
46+
* Please note that this certificate should allow usage for TLS web client authentication (as specified in RFC 3280)
47+
1. Obtain TLS certificate and private key for each plugin or group of plugins.
48+
* Please note that this certificate should allow usage for TLS web server authentication (as specified in RFC 3280)
49+
1. Obtain and locate the CA certificates that are necessary to authenticate framework and plugin certificates.
50+
51+
Process of acquiring a TLS certificate is a complex one. Every organization has its specific rules on security, thus the details are not given here.
52+
53+
We do provide a short guide on obtaining self-signed certificates that may be used for tests outside production environment; see [Obtaining self-signed TLS certificates for tests](#obtaining-self-signed-tls-certificates-for-tests).
54+
55+
### Enabling secure communication
56+
57+
Secure communication is enabled by passing the required paths to programs: `snapteld`, and plugin (via `snaptel`). The minimum paths necessary are:
58+
* for `snapteld`: `--tls-cert`, `--tls-key`,
59+
* for plugins (`snaptel`): `--plugin-cert`, `--plugin-key`.
60+
61+
The required paths are sufficient and necessary to enable TLS. Daemon (`snapteld`) and plugins (via `snaptel`) will refuse to start if certificate or key file argument is missing.
62+
63+
### Using system-installed CA certificates
64+
65+
Framework and plugins need CA certificates to validate each other's certificate. The CA certificates may be obtained in two ways:
66+
* by passing a list of CA certificate paths directly as a parameter, e.g.: `--ca-cert-paths=/tmp/small-setup-ca.crt:/tmp/medium-setup-ca.crt:/tmp/ca-certs/`, `--plugin-ca-certs`
67+
* plugin as well as framework will examine each path in the list and either load a file directly or list directory contents and load the enumerated files (e.g.: the files in `/tmp/ca-certs/` folder)
68+
* by relying on default CA certificate discovery mechanism
69+
* plugin and framework will by default load certificates from system (if no paths were given as parameter). Each OS has its own specific locations, e.g.: `/etc/ssl/certs` on Ubuntu. This mechanism is provided by Go language, and is only available on selected OSes.
70+
System CA certificates may also be loaded explicitly by listing system locations explicitly, e.g.: `--ca-cert-paths /etc/ssl/certs:/tmp/snaptest-ca.crt`
71+
72+
## More information
73+
74+
### Exclusive security
75+
76+
It's important to note that once secure plugin communication is enabled in framework, only secure connections may be established.
77+
78+
In other words: attempting to load insecure plugin in framework will result in an error.
79+
80+
### Relation to other functionalities
81+
82+
Several modes of operation do not fully support secure communication:
83+
* distributed workflow is not covered by secure communication,
84+
* tribe doesn't support secure communication; `snapteld` will refuse to start in tribe mode if configured with secure communication,
85+
* plugin and task autodiscovery doesn't support secure communication; `snapteld` will refuse to start with autodiscovery path and secure communication enabled.
86+
87+
### Obtaining self-signed TLS certificates for tests
88+
89+
The following intstructions will result in TLS certificate files. These files may be used for manual tests.
90+
1. Install tool [certstrap](https://github.com/square/certstrap) for generating test certificates. Further steps will assume that `certstrap` is available under `$PATH` location.
91+
1. Generate root CA certificate:
92+
```
93+
certstrap init --cn "snaptest-ca" --o "snaptest" --ou "ca" --key-bits 2048 --years 1 --passphrase '
94+
```
95+
1. **optional** Install root CA certificate in the system:
96+
```
97+
sudo cp out/snaptest-ca.crt /usr/local/share/ca-certificates/; sudo update-ca-certificates --verbose --fresh
98+
```
99+
1. Generate server certificate and key to use with plugins:
100+
```
101+
certstrap request-cert --cn "snaptest-srv" --ip "127.0.0.1" --domain "localhost" --passphrase '' --key-bits 2048 --o "snaptest" --ou "server"
102+
certstrap sign "snaptest-srv" --CA "snaptest-ca" --passphrase '' --years 1
103+
```
104+
1. Generate client certificate and key to use with `snapteld`:
105+
```
106+
certstrap request-cert --cn "snaptest-cli" --ip "127.0.0.1" --domain "localhost" --passphrase '' --key-bits 2048 --o "snaptest" --ou "client"
107+
certstrap sign "snaptest-cli" --CA "snaptest-ca" --passphrase '' --years 1
108+
```
109+
1. Copy server and client certificates into common location, e.g.: `/tmp`:
110+
```
111+
for unit in srv cli; do for fname in crt key; do cp out/snaptest-$unit.$fname /tmp; done; done
112+
```
113+
The following files are relevant for running the tests:
114+
* `/tmp/snaptest-cli.crt`, `/tmp/snaptest-cli.key` - these are the certificate and private key files for `snapteld`,
115+
* `/tmp/snaptest-srv.crt`, `/tmp/snaptest-srv.key` - these are the certificate and private key files for plugin,
116+
* `/tmp/snaptest-ca.crt` - this is the CA certificate that should be used to authenticate framework and plugins.
117+
118+
## More information
119+
120+
* [SNAPTELD_CONFIGURATION.md](SNAPTELD_CONFIGURATION.md)
121+
* [SNAPTELD](SNAPTELD.md)
122+
* [SNAPTELD](SNAPTELD.md)
123+
* [TRIBE.md](TRIBE.md)
124+
* [DISTRIBUTED_WORKFLOW_ARCHITECTURE](DISTRIBUTED_WORKFLOW_ARCHITECTURE.md)

docs/SNAPTEL.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ help, h Shows a list of commands or help for one command
8787
$ snaptel plugin command [command options] [arguments...]
8888
```
8989
```
90-
load load <plugin_path> [--plugin-cert=<plugin_cert_path> --plugin-key=<plugin_key_path>]
90+
load load <plugin_path> [--plugin-cert=<plugin_cert_path> --plugin-key=<plugin_key_path> --plugin-ca-certs=<ca_cert_paths>]
9191
unload unload <plugin_type> <plugin_name> <plugin_version>
92-
swap swap <load_plugin_path> <unload_plugin_type>:<unload_plugin_name>:<unload_plugin_version> or swap <load_plugin_path> -t <unload_plugin_type> -n <unload_plugin_name> -v <unload_plugin_version> [--plugin-cert=<plugin_cert_path> --plugin-key=<plugin_key_path>
92+
swap swap <load_plugin_path> <unload_plugin_type>:<unload_plugin_name>:<unload_plugin_version> or swap <load_plugin_path> -t <unload_plugin_type> -n <unload_plugin_name> -v <unload_plugin_version> [--plugin-cert=<plugin_cert_path> --plugin-key=<plugin_key_path> [--plugin-ca-certs=<ca_cert_paths>] ]
9393
list list
9494
help, h Shows a list of commands or help for one command
9595
```
@@ -205,3 +205,6 @@ $ snaptel plugin unload collector mock <version>
205205
$ snaptel plugin unload processor passthru <version>
206206
$ snaptel plugin unload publisher publisher <version>
207207
```
208+
209+
## More information
210+
* [SECURE_PLUGIN_COMMUNICATION](SECURE_PLUGIN_COMMUNICATION.md)

docs/SNAPTELD.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ $ snapteld [global options] command [command options] [arguments...]
4444
--control-listen-port value Listen port for control RPC server (default: 8082) [$SNAP_CONTROL_LISTEN_PORT]
4545
--control-listen-addr value Listen address for control RPC server [$SNAP_CONTROL_LISTEN_ADDR]
4646
--temp_dir_path value Temporary path for loading plugins [$SNAP_TEMP_DIR_PATH]
47-
--tls-cert value A path to PEM-encoded certificate to use for TLS channels
48-
--tls-key value A path to PEM-encoded private key file to use for TLS channels
47+
--tls-cert value A path to PEM-encoded certificate for framework to use for securing communication channels to plugins over TLS
48+
--tls-key value A path to PEM-encoded private key file for framework to use for securing communication channels to plugins over TLS
49+
--ca-cert-paths List of paths (directories/files) to CA certificates for validating plugin certificates in secure TLS communication
4950
--work-manager-queue-size value Size of the work manager queue (default: 25) [$WORK_MANAGER_QUEUE_SIZE]
5051
--work-manager-pool-size value Size of the work manager pool (default: 4) [$WORK_MANAGER_POOL_SIZE]
5152
--disable-api, -d Disable the agent REST API
@@ -74,6 +75,8 @@ $ snapteld --version
7475
$ snapteld --log-level 4
7576
$ snapteld --auto-discover /opt/snap/plugins/
7677
$ snapteld --log-level 1 --plugin-trust 2 --keyring-paths /etc/snap/keyrings
78+
$ snapteld --log-level 1 --tls-cert /etc/snap/cert/snapteld.crt --tls-key /etc/snap/key/snapteld.key
79+
--ca-cert-paths /etc/ssl/certs/sample_organization_CA.crt:/etc/snap/ca/
7780
```
7881

7982
### Debug output
@@ -157,3 +160,4 @@ INFO[2017-01-09T12:55:05-08:00] snapteld started
157160
* [REST_API.md](REST_API.md)
158161
* [PLUGIN_SIGNING.md](PLUGIN_SIGNING.md)
159162
* [TRIBE.md](TRIBE.md)
163+
* [SECURE_PLUGIN_COMMUNICATION](SECURE_PLUGIN_COMMUNICATION.md)

docs/SNAPTELD_CONFIGURATION.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ control:
108108
# before failing. Snap will not disable a plugin due to failures when this value is -1.
109109
max_plugin_restarts: 10
110110

111+
## Secure plugin communication optional parameters:
112+
# tls_cert_path sets the TLS certificate path to enable secure plugin communication
113+
# and authenticate itself to plugins. Requires also: tls_key_path.
114+
tls_cert_path: /tmp/snaptest-cli.crt
115+
# tls_key_path sets the TLS key path to enable secure plugin communication and
116+
# authenticate itself to plugins. Requires also: tls_cert_path.
117+
tls_key_path: /tmp/snaptest-cli.key
118+
# ca_cert_paths sets the list of filesystem paths (files/directories) to CA certificates
119+
# for use in validating
120+
ca_cert_paths: /tmp/small-setup-ca.crt:/tmp/medium-setup-ca.crt:/tmp/ca-certs/
121+
111122
# plugins section contains plugin config settings that will be applied for
112123
# plugins across tasks.
113124
plugins:

examples/configs/snap-config-sample.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"keyring_paths":"/etc/snap/keyrings",
1616
"temp_dir_path":"/tmp",
1717
"plugin_trust_level":0,
18+
"tls_cert_path": "/tmp/snaptest-cli.crt",
19+
"tls_key_path": "/tmp/snaptest-cli.key",
20+
"ca_cert_paths": "/tmp/small-setup-ca.crt:/tmp/medium-setup-ca.crt:/tmp/ca-certs/",
1821
"plugins":{
1922
"all":{
2023
"password":"p@ssw0rd"

examples/configs/snap-config-sample.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ control:
7272
# before failing. Snap will not disable a plugin due to failures when this value is -1.
7373
max_plugin_restarts: 10
7474

75+
## Secure plugin communication optional parameters:
76+
# tls_cert_path sets the TLS certificate path to enable secure plugin communication
77+
# and authenticate itself to plugins. Requires also: tls_key_path.
78+
tls_cert_path: /tmp/snaptest-cli.crt
79+
# tls_key_path sets the TLS key path to enable secure plugin communication and
80+
# authenticate itself to plugins. Requires also: tls_cert_path.
81+
tls_key_path: /tmp/snaptest-cli.key
82+
# ca_cert_paths sets the list of filesystem paths (files/directories) to CA certificates
83+
# for use in validating
84+
ca_cert_paths: /tmp/small-setup-ca.crt:/tmp/medium-setup-ca.crt:/tmp/ca-certs/
85+
7586
# plugins section contains plugin config settings that will be applied for
7687
# plugins across tasks.
7788
plugins:

0 commit comments

Comments
 (0)