4.6. TLS Erlang Distribution

The main purpose is specifically to allow using TLS for Erlang distribution between nodes, with the ability to connect to some nodes using TCP as well. TLS distribution will enhance data security during data migration between nodes.

This section describes how to enable TLS distribution for additional verification and security.

Reference: Using TLS for Erlang Distribution

4.6.1. Generate Certificate

For TLS to work properly, at least one public key and one certificate must be specified. In the following example (couch_ssl_dist.conf), the PEM file contains the certificate and its private key.

  1. [{server,
  2. [{certfile, "</path/to/erlserver.pem>"},
  3. {secure_renegotiate, true}]},
  4. {client,
  5. [{secure_renegotiate, true}]}].

The following command is an example of generating a certificate (PEM) file.

  1. $ openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
  2. $ cat key.pem cert.pem > erlserver.pem && rm key.pem cert.pem

Note

This is not an endorsement of a specific expiration limit, key size or algorithm.

4.6.2. Config Settings

To enable TLS distribution, make sure to set custom parameters in vm.args.

  1. # Don't forget to override the paths to point to your cert and conf file!
  2. -proto_dist couch
  3. -couch_dist no_tls \"clouseau@127.0.0.1\"
  4. -ssl_dist_optfile <path/to/couch_ssl_dist.conf>

Note

  • The default value of no_tls is false. If the user does not set any no_tls flag, all nodes will use TCP.

  • To ensure “search” works, make sure to set no_tls option for the clouseau node. By default, this will be "clouseau@127.0.0.1".

The no_tls flag can have these values:

  1. Use TLS only, set to false (default value), such as:

    1. -couch_dist no_tls false
  2. Use TCP only, set to true, such as:

    1. -couch_dist no_tls true
  3. Specify some nodes to use TCP, others to use TLS, such as:

    1. # Specify node1 and node2 to use TCP, others use TLS
    2. -couch_dist no_tls \"node1@127.0.0.1\"
    3. -couch_dist no_tls \"node2@127.0.0.1\"
    1. # Any nodes end with "@127.0.0.1" will use TCP, others use TLS
    2. -couch_dist no_tls \"*@127.0.0.1\"

    Note

    Asterisk(*): matches a sequence of zero or more occurrences of the regular expression.

    Question mark(?): matches zero or one occurrences of the regular expression.

4.6.3. Connect to Remsh

Start Erlang using a remote shell connected to Node.

  • If the node uses TCP:

    1. $ ./remsh
  • If the node uses TLS:

    1. $ ./remsh -t <path/to/couch_ssl_dist.conf>