Skip to content

Commit b152d7f

Browse files
committed
TLS docs
1 parent de8c702 commit b152d7f

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

docs/certificates.rst

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
TLS
2+
---
3+
4+
When you need fine-grained control over TLS settings, you build a Python
5+
:class:`ssl.SSLContext` and hand it to the :class:`arangoasync.http.DefaultHTTPClient` class.
6+
Here are the most common patterns.
7+
8+
9+
Basic client-side HTTPS with default settings
10+
=============================================
11+
12+
Create a “secure by default” client context. This will verify server certificates against your
13+
OS trust store and check hostnames.
14+
15+
**Example:**
16+
17+
.. code-block:: python
18+
19+
from arangoasync import ArangoClient
20+
from arangoasync.auth import Auth
21+
from arangoasync.http import DefaultHTTPClient
22+
import ssl
23+
24+
# Create a default client context.
25+
ssl_ctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)
26+
http_client = DefaultHTTPClient(ssl_context=ssl_ctx)
27+
28+
# Initialize the client for ArangoDB.
29+
client = ArangoClient(
30+
hosts="https://localhost:8529",
31+
http_client=http_client,
32+
)
33+
34+
Custom CA bundle
35+
================
36+
37+
If you have a custom CA file, this allows you to trust the private CA.
38+
39+
**Example:**
40+
41+
.. code-block:: python
42+
43+
from arangoasync import ArangoClient
44+
from arangoasync.auth import Auth
45+
from arangoasync.http import DefaultHTTPClient
46+
import ssl
47+
48+
# Use a custom CA bundle.
49+
ssl_ctx = ssl.create_default_context(cafile="path/to/ca.pem")
50+
http_client = DefaultHTTPClient(ssl_context=ssl_ctx)
51+
52+
# Initialize the client for ArangoDB.
53+
client = ArangoClient(
54+
hosts="https://localhost:8529",
55+
http_client=http_client,
56+
)
57+
58+
Disabling certificate verification
59+
==================================
60+
61+
If you want to disable *all* certification checks (not recommended), create an unverified
62+
context.
63+
64+
**Example:**
65+
66+
.. code-block:: python
67+
68+
from arangoasync import ArangoClient
69+
from arangoasync.auth import Auth
70+
from arangoasync.http import DefaultHTTPClient
71+
import ssl
72+
73+
# Disable certificate verification.
74+
ssl_ctx = ssl._create_unverified_context()
75+
http_client = DefaultHTTPClient(ssl_context=ssl_ctx)
76+
77+
# Initialize the client for ArangoDB.
78+
client = ArangoClient(
79+
hosts="https://localhost:8529",
80+
http_client=http_client,
81+
)
82+
83+
Use a client certificate chain
84+
==============================
85+
86+
**Example:**
87+
88+
.. code-block:: python
89+
90+
from arangoasync import ArangoClient
91+
from arangoasync.auth import Auth
92+
from arangoasync.http import DefaultHTTPClient
93+
import ssl
94+
95+
# Load a certificate chain.
96+
ssl_ctx = ssl.create_default_context(cafile="path/to/ca.pem")
97+
ssl_ctx.load_cert_chain(certfile="path/to/cert.pem", keyfile="path/to/key.pem")
98+
http_client = DefaultHTTPClient(ssl_context=ssl_ctx)
99+
100+
# Initialize the client for ArangoDB.
101+
client = ArangoClient(
102+
hosts="https://localhost:8529",
103+
http_client=http_client,
104+
)
105+
106+
.. note::
107+
For best performance, re-use one SSLContext across many requests/sessions to amortize handshake cost.
108+
109+
If you want to have fine-grained control over the HTTP connection, you should define
110+
your HTTP client as described in the :ref:`HTTP` section.

docs/http.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. _HTTP:
2+
3+
HTTP
4+
----

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ Contents
6565

6666
cursor
6767
authentication
68+
http
69+
certificates
6870
compression
6971
errors
7072
errno

0 commit comments

Comments
 (0)