|
| 1 | +.. Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 2 | +.. use this file except in compliance with the License. You may obtain a copy of |
| 3 | +.. the License at |
| 4 | +.. |
| 5 | +.. http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +.. |
| 7 | +.. Unless required by applicable law or agreed to in writing, software |
| 8 | +.. distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +.. WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +.. License for the specific language governing permissions and limitations under |
| 11 | +.. the License. |
| 12 | +
|
| 13 | +.. _cluster/tls_erlang_distribution: |
| 14 | + |
| 15 | +======================= |
| 16 | +TLS Erlang Distribution |
| 17 | +======================= |
| 18 | +The main purpose is specifically to allow using TLS for Erlang distribution |
| 19 | +between nodes, with the ability to connect to some nodes using TCP as well. |
| 20 | +TLS distribution will enhance data security during data migration between |
| 21 | +nodes. |
| 22 | + |
| 23 | +This section describes how to enable TLS distribution for additional |
| 24 | +verification and security. |
| 25 | + |
| 26 | +Reference: `Using TLS for Erlang Distribution`_ |
| 27 | + |
| 28 | +.. _Using TLS for Erlang Distribution: https://erlang.org/doc/apps/ssl/ssl_distribution.html |
| 29 | + |
| 30 | +Generate Certificate |
| 31 | +==================== |
| 32 | +For TLS to work properly, at least one public key and one certificate must be |
| 33 | +specified. In the following example (couch_ssl_dist.conf), the PEM file contains |
| 34 | +the ``certificate`` and its ``private key``. |
| 35 | + |
| 36 | + .. code-block:: text |
| 37 | +
|
| 38 | + [{server, |
| 39 | + [{certfile, "</path/to/erlserver.pem>"}, |
| 40 | + {secure_renegotiate, true}]}, |
| 41 | + {client, |
| 42 | + [{secure_renegotiate, true}]}]. |
| 43 | +
|
| 44 | +The following command is an example of generating a certificate (PEM) file. |
| 45 | + |
| 46 | + .. code-block:: bash |
| 47 | +
|
| 48 | + $ openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem |
| 49 | + $ cat key.pem cert.pem > erlserver.pem && rm key.pem cert.pem |
| 50 | +
|
| 51 | + .. note:: |
| 52 | + This is **not** an endorsement of a specific expiration limit, |
| 53 | + key size or algorithm. |
| 54 | + |
| 55 | +Config Settings |
| 56 | +=============== |
| 57 | +To enable TLS distribution, make sure to set custom parameters in ``vm.args``. |
| 58 | + |
| 59 | + .. code-block:: text |
| 60 | +
|
| 61 | + # Don't forget to override the paths to point to your cert and conf file! |
| 62 | +
|
| 63 | + -proto_dist couch |
| 64 | + -couch_dist no_tls \"[email protected]\" |
| 65 | + -ssl_dist_optfile <path/to/couch_ssl_dist.conf> |
| 66 | +
|
| 67 | + .. note:: |
| 68 | + * The default value of ``no_tls`` is ``false``. If the user does not |
| 69 | + set any ``no_tls`` flag, all nodes will use ``TCP``. |
| 70 | + * To ensure "search" works, make sure to set ``no_tls`` option for the |
| 71 | + `` clouseau`` node. By default, this will be `` "[email protected]"``. |
| 72 | + |
| 73 | +The ``no_tls`` flag can have these values: |
| 74 | + |
| 75 | +#. Use ``TLS`` only, set to ``false`` (default value), such as: |
| 76 | + |
| 77 | + .. code-block:: text |
| 78 | +
|
| 79 | + -couch_dist no_tls false |
| 80 | +
|
| 81 | +#. Use ``TCP`` only, set to ``true``, such as: |
| 82 | + |
| 83 | + .. code-block:: text |
| 84 | +
|
| 85 | + -couch_dist no_tls true |
| 86 | +
|
| 87 | +#. Specify some nodes to use ``TCP``, others to use ``TLS``, such as: |
| 88 | + |
| 89 | + .. code-block:: text |
| 90 | +
|
| 91 | + # Specify node1 and node2 to use TCP, others use TLS |
| 92 | +
|
| 93 | + -couch_dist no_tls \"[email protected]\" |
| 94 | + -couch_dist no_tls \"[email protected]\" |
| 95 | +
|
| 96 | + .. code-block:: text |
| 97 | +
|
| 98 | + # Any nodes end with "@127.0.0.1" will use TCP, others use TLS |
| 99 | +
|
| 100 | + -couch_dist no_tls \"*@127.0.0.1\" |
| 101 | +
|
| 102 | + .. note:: |
| 103 | + **Asterisk(*)**: matches a sequence of zero or more occurrences of the regular |
| 104 | + expression. |
| 105 | + |
| 106 | + **Question mark(?)**: matches zero or one occurrences of the regular expression. |
| 107 | + |
| 108 | +Connect to Remsh |
| 109 | +================ |
| 110 | +Start Erlang using a remote shell connected to Node. |
| 111 | + |
| 112 | +* If the node uses ``TCP``: |
| 113 | + |
| 114 | + .. code-block:: bash |
| 115 | +
|
| 116 | + $ ./remsh |
| 117 | +
|
| 118 | +* If the node uses ``TLS``: |
| 119 | + |
| 120 | + .. code-block:: bash |
| 121 | +
|
| 122 | + $ ./remsh -t <path/to/couch_ssl_dist.conf> |
0 commit comments