summaryrefslogtreecommitdiff
path: root/docs/tls.rst
blob: 0f318ff643895abea127223053882cc516516754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Using TLS
=========

.. py:module:: docker.tls

Both the main :py:class:`~docker.client.Client` and low-level
:py:class:`~docker.api.client.APIClient` can connect to the Docker daemon with TLS.

This is all configured automatically for you if you're using :py:func:`~docker.client.from_env`, but if you need some extra control it is possible to configure it manually by using a :py:class:`TLSConfig` object.

Examples
--------

For example, to check the server against a specific CA certificate:

.. code-block:: python

  tls_config = docker.tls.TLSConfig(ca_cert='/path/to/ca.pem')
  client = docker.Client(base_url='<https_url>', tls=tls_config)

This is the equivalent of ``docker --tlsverify --tlscacert /path/to/ca.pem ...``.

To authenticate with client certs:

.. code-block:: python

  tls_config = docker.tls.TLSConfig(
    client_cert=('/path/to/client-cert.pem', '/path/to/client-key.pem')
  )
  client = docker.Client(base_url='<https_url>', tls=tls_config)

This is the equivalent of ``docker --tls --tlscert /path/to/client-cert.pem --tlskey /path/to/client-key.pem ...``.

Reference
---------

.. autoclass:: TLSConfig()