Skip to content

Commit 17f9750

Browse files
committed
box.cfg: add the 'Traffic encryption' section
1 parent a4fb69c commit 17f9750

File tree

1 file changed

+276
-0
lines changed

1 file changed

+276
-0
lines changed

doc/concepts/configuration/configuration_code.rst

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,282 @@ In case of a single URI, the following syntax also works:
319319
}
320320
321321
322+
.. _configuration_code_iproto-encryption:
323+
324+
Traffic encryption
325+
------------------
326+
327+
.. admonition:: Enterprise Edition
328+
:class: fact
329+
330+
Traffic encryption is supported by the `Enterprise Edition <https://www.tarantool.io/compare/>`_ only.
331+
332+
Since version 2.10.0, Tarantool Enterprise Edition has the built-in support for using SSL to encrypt the client-server communications over :ref:`binary connections <box_protocol-iproto_protocol>`,
333+
that is, between Tarantool instances in a cluster or connecting to an instance via connectors using :doc:`net.box </reference/reference_lua/net_box>`.
334+
335+
Tarantool uses the OpenSSL library that is included in the delivery package.
336+
Note that SSL connections use only TLSv1.2.
337+
338+
.. _configuration_code_iproto-encryption-config:
339+
340+
Configuration
341+
~~~~~~~~~~~~~
342+
343+
To configure traffic encryption, you need to set the special :ref:`URI parameters <index-uri-several-params>` for a particular connection.
344+
The parameters can be set for the following ``box.cfg`` options and ``nex.box`` method:
345+
346+
* :ref:`box.cfg.listen <cfg_basic-listen>` -- on the server side.
347+
* :ref:`box.cfg.replication <cfg_replication-replication>`--on the client side.
348+
* :ref:`net_box_object.connect() <net_box-connect>`--on the client side.
349+
350+
Below is the list of the parameters.
351+
In the :ref:`next section <configuration_code_iproto-encryption-config-sc>`, you can find details and examples on what should be configured on both the server side and the client side.
352+
353+
* ``transport`` -- enables SSL encryption for a connection if set to ``ssl``.
354+
The default value is ``plain``, which means the encryption is off. If the parameter is not set, the encryption is off too.
355+
Other encryption-related parameters can be used only if the ``transport = 'ssl'`` is set.
356+
357+
Example:
358+
359+
.. literalinclude:: /code_snippets/snippets/replication/instances.enabled/ssl/myapp.lua
360+
:language: lua
361+
:start-at: net.box
362+
:end-before: return connection
363+
:dedent:
364+
365+
* ``ssl_key_file`` -- a path to a private SSL key file.
366+
Mandatory for a server.
367+
For a client, it's mandatory if the ``ssl_ca_file`` parameter is set for a server; otherwise, optional.
368+
If the private key is encrypted, provide a password for it in the ``ssl_password`` or ``ssl_password_file`` parameter.
369+
370+
* ``ssl_cert_file`` -- a path to an SSL certificate file.
371+
Mandatory for a server.
372+
For a client, it's mandatory if the ``ssl_ca_file`` parameter is set for a server; otherwise, optional.
373+
374+
* ``ssl_ca_file`` -- a path to a trusted certificate authorities (CA) file. Optional. If not set, the peer won't be checked for authenticity.
375+
376+
Both a server and a client can use the ``ssl_ca_file`` parameter:
377+
378+
* If it's on the server side, the server verifies the client.
379+
* If it's on the client side, the client verifies the server.
380+
* If both sides have the CA files, the server and the client verify each other.
381+
382+
* ``ssl_ciphers`` -- a colon-separated (``:``) list of SSL cipher suites the connection can use. See the :ref:`configuration_code_iproto-encryption-ciphers` section for details. Optional.
383+
Note that the list is not validated: if a cipher suite is unknown, Tarantool just ignores it, doesn't establish the connection and writes to the log that no shared cipher found.
384+
385+
* ``ssl_password`` -- a password for an encrypted private SSL key. Optional. Alternatively, the password
386+
can be provided in ``ssl_password_file``.
387+
388+
* ``ssl_password_file`` -- a text file with one or more passwords for encrypted private SSL keys
389+
(each on a separate line). Optional. Alternatively, the password can be provided in ``ssl_password``.
390+
391+
Tarantool applies the ``ssl_password`` and ``ssl_password_file`` parameters in the following order:
392+
393+
1. If ``ssl_password`` is provided, Tarantool tries to decrypt the private key with it.
394+
2. If ``ssl_password`` is incorrect or isn't provided, Tarantool tries all passwords from ``ssl_password_file``
395+
one by one in the order they are written.
396+
3. If ``ssl_password`` and all passwords from ``ssl_password_file`` are incorrect,
397+
or none of them is provided, Tarantool treats the private key as unencrypted.
398+
399+
Configuration example:
400+
401+
.. code-block:: lua
402+
403+
box.cfg{ listen = {
404+
uri = 'localhost:3301',
405+
params = {
406+
transport = 'ssl',
407+
ssl_key_file = '/path_to_key_file',
408+
ssl_cert_file = '/path_to_cert_file',
409+
ssl_ciphers = 'HIGH:!aNULL',
410+
ssl_password = 'topsecret'
411+
}
412+
}}
413+
414+
.. _configuration_code_iproto-encryption-ciphers:
415+
416+
Supported ciphers
417+
*****************
418+
419+
Tarantool Enterprise supports the following cipher suites:
420+
421+
* ECDHE-ECDSA-AES256-GCM-SHA384
422+
* ECDHE-RSA-AES256-GCM-SHA384
423+
* DHE-RSA-AES256-GCM-SHA384
424+
* ECDHE-ECDSA-CHACHA20-POLY1305
425+
* ECDHE-RSA-CHACHA20-POLY1305
426+
* DHE-RSA-CHACHA20-POLY1305
427+
* ECDHE-ECDSA-AES128-GCM-SHA256
428+
* ECDHE-RSA-AES128-GCM-SHA256
429+
* DHE-RSA-AES128-GCM-SHA256
430+
* ECDHE-ECDSA-AES256-SHA384
431+
* ECDHE-RSA-AES256-SHA384
432+
* DHE-RSA-AES256-SHA256
433+
* ECDHE-ECDSA-AES128-SHA256
434+
* ECDHE-RSA-AES128-SHA256
435+
* DHE-RSA-AES128-SHA256
436+
* ECDHE-ECDSA-AES256-SHA
437+
* ECDHE-RSA-AES256-SHA
438+
* DHE-RSA-AES256-SHA
439+
* ECDHE-ECDSA-AES128-SHA
440+
* ECDHE-RSA-AES128-SHA
441+
* DHE-RSA-AES128-SHA
442+
* AES256-GCM-SHA384
443+
* AES128-GCM-SHA256
444+
* AES256-SHA256
445+
* AES128-SHA256
446+
* AES256-SHA
447+
* AES128-SHA
448+
* GOST2012-GOST8912-GOST8912
449+
* GOST2001-GOST89-GOST89
450+
451+
Tarantool Enterprise static build has the embedded engine to support the GOST cryptographic algorithms.
452+
If you use these algorithms for traffic encryption, specify the corresponding cipher suite in the ``ssl_ciphers`` parameter, for example:
453+
454+
.. code-block:: lua
455+
456+
box.cfg{ listen = {
457+
uri = 'localhost:3301',
458+
params = {
459+
transport = 'ssl',
460+
ssl_key_file = '/path_to_key_file',
461+
ssl_cert_file = '/path_to_cert_file',
462+
ssl_ciphers = 'GOST2012-GOST8912-GOST8912'
463+
}
464+
}}
465+
466+
For detailed information on SSL ciphers and their syntax, refer to `OpenSSL documentation <https://www.openssl.org/docs/man1.1.1/man1/ciphers.html>`__.
467+
468+
Using environment variables
469+
***************************
470+
471+
The URI parameters for traffic encryption can also be set via :ref:`environment variables <box-cfg-params-env>`, for example:
472+
473+
.. code-block:: bash
474+
475+
export TT_LISTEN="localhost:3301?transport=ssl&ssl_cert_file=/path_to_cert_file&ssl_key_file=/path_to_key_file"
476+
477+
478+
.. _configuration_code_iproto-encryption-config-sc:
479+
480+
Server-client configuration details
481+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
482+
483+
When configuring the traffic encryption, you need to specify the necessary parameters on both the server side and the client side.
484+
Below you can find the summary on the options and parameters to be used and :ref:`examples of configuration <configuration_code_iproto-encryption-config-example>`.
485+
486+
**Server side**
487+
488+
* Is configured via the ``box.cfg.listen`` option.
489+
* Mandatory URI parameters: ``transport``, ``ssl_key_file`` and ``ssl_cert_file``.
490+
* Optional URI parameters: ``ssl_ca_file``, ``ssl_ciphers``, ``ssl_password``, and ``ssl_password_file``.
491+
492+
493+
**Client side**
494+
495+
* Is configured via the ``box.cfg.replication`` option (see :ref:`details <configuration_code_iproto-encryption-config-example>`) or ``net_box_object.connect()``.
496+
497+
Parameters:
498+
499+
* If the server side has only the ``transport``, ``ssl_key_file`` and ``ssl_cert_file`` parameters set,
500+
on the client side, you need to specify only ``transport = ssl`` as the mandatory parameter.
501+
All other URI parameters are optional.
502+
503+
* If the server side also has the ``ssl_ca_file`` parameter set,
504+
on the client side, you need to specify ``transport``, ``ssl_key_file`` and ``ssl_cert_file`` as the mandatory parameters.
505+
Other parameters -- ``ssl_ca_file``, ``ssl_ciphers``, ``ssl_password``, and ``ssl_password_file`` -- are optional.
506+
507+
508+
.. _configuration_code_iproto-encryption-config-example:
509+
510+
Configuration examples
511+
**********************
512+
513+
Suppose, there is a :ref:`master-replica <replication-master_replica_bootstrap>` set with two Tarantool instances:
514+
515+
* 127.0.0.1:3301 -- master (server)
516+
* 127.0.0.1:3302 -- replica (client).
517+
518+
Examples below show the configuration related to connection encryption for two cases:
519+
when the trusted certificate authorities (CA) file is not set on the server side and when it does.
520+
Only mandatory URI parameters are mentioned in these examples.
521+
522+
1. **Without CA**
523+
524+
* 127.0.0.1:3301 -- master (server)
525+
526+
.. code-block:: lua
527+
528+
box.cfg{
529+
listen = {
530+
uri = '127.0.0.1:3301',
531+
params = {
532+
transport = 'ssl',
533+
ssl_key_file = '/path_to_key_file',
534+
ssl_cert_file = '/path_to_cert_file'
535+
}
536+
}
537+
}
538+
539+
* 127.0.0.1:3302 -- replica (client)
540+
541+
.. code-block:: lua
542+
543+
box.cfg{
544+
listen = {
545+
uri = '127.0.0.1:3302',
546+
params = {transport = 'ssl'}
547+
},
548+
replication = {
549+
uri = 'username:[email protected]:3301',
550+
params = {transport = 'ssl'}
551+
},
552+
read_only = true
553+
}
554+
555+
2. **With CA**
556+
557+
* 127.0.0.1:3301 -- master (server)
558+
559+
.. code-block:: lua
560+
561+
box.cfg{
562+
listen = {
563+
uri = '127.0.0.1:3301',
564+
params = {
565+
transport = 'ssl',
566+
ssl_key_file = '/path_to_key_file',
567+
ssl_cert_file = '/path_to_cert_file',
568+
ssl_ca_file = '/path_to_ca_file'
569+
}
570+
}
571+
}
572+
573+
* 127.0.0.1:3302 -- replica (client)
574+
575+
.. code-block:: lua
576+
577+
box.cfg{
578+
listen = {
579+
uri = '127.0.0.1:3302',
580+
params = {
581+
transport = 'ssl',
582+
ssl_key_file = '/path_to_key_file',
583+
ssl_cert_file = '/path_to_cert_file'
584+
}
585+
},
586+
replication = {
587+
uri = 'username:[email protected]:3301',
588+
params = {
589+
transport = 'ssl',
590+
ssl_key_file = '/path_to_key_file',
591+
ssl_cert_file = '/path_to_cert_file'
592+
}
593+
},
594+
read_only = true
595+
}
596+
597+
322598
323599
.. _configuration_code_run_instance_tarantool:
324600

0 commit comments

Comments
 (0)