1
1
.. _https_connection:
2
2
3
3
========================
4
- HTTPS Connection support
4
+ HTTPS connection support
5
5
========================
6
6
7
- The CrateDB Client is able to connect via https .
7
+ The CrateDB client is able to connect via HTTPS .
8
8
9
- .. note::
9
+ A check against a specific CA certificate can be made by creating the client
10
+ with the path to the CA certificate file using the keyword argument
11
+ ``ca_cert``.
10
12
11
- By default, ssl server certificates are **NOT** verified.
13
+ .. note::
12
14
13
- To enable verification, use the keyword argument ``verify_ssl_cert``.
14
- If it is set to ``True``, the server certificate is validated, if set to
15
- ``False`` or ommitted, no verification will be done whatsoever .
15
+ By default, SSL server certificates are verified. To disable verification,
16
+ use the keyword argument ``verify_ssl_cert``. If it is set to ``False``,
17
+ server certificate validation will be skipped .
16
18
17
- One can check against a single CA certificate
18
- by creating the client with the a path to a CA certificate file to check against
19
- in keyword argument ``ca_cert``.
20
19
21
20
.. rubric:: Table of Contents
22
21
@@ -26,45 +25,44 @@ in keyword argument ``ca_cert``.
26
25
Examples
27
26
--------
28
27
29
- By default, certificates are not verified. This call is against a server with
30
- a self signed certificate::
31
-
32
- >>> http_client = HttpClient([crate_host])
33
- >>> http_client.server_infos(http_client._get_server())
34
- ('https://localhost:65534', 'test', '0.0.0')
35
-
36
28
When switching on verification without a ``ca_cert`` file provided, the
37
- connection will fail::
29
+ connection will fail because we are using a self-signed server certificate ::
38
30
39
- >>> verifying_client = HttpClient([crate_host], verify_ssl_cert=True )
31
+ >>> verifying_client = HttpClient([crate_host])
40
32
>>> verifying_client.server_infos(crate_host)
41
33
Traceback (most recent call last):
42
34
...
43
35
crate.client.exceptions.ConnectionError: Server not available, ...certificate verify failed...
44
36
45
- Also when providing an invalid ``ca_cert`` an error is raised::
37
+ Also, when providing an invalid ``ca_cert`` an error is raised::
46
38
47
- >>> verifying_client = HttpClient([crate_host], ca_cert=invalid_ca_cert, verify_ssl_cert=True )
39
+ >>> verifying_client = HttpClient([crate_host], ca_cert=invalid_ca_cert)
48
40
>>> verifying_client.server_infos(crate_host)
49
41
Traceback (most recent call last):
50
42
...
51
43
crate.client.exceptions.ConnectionError: Server not available, ...certificate verify failed...
52
44
53
- Without verification, the given ``ca_cert`` is ignored and the connection will be
54
- established, to Eves satisfaction.
45
+ Connecting to a host whose certificate is verified with a valid CA certificate::
46
+
47
+ >>> verifying_valid_client = HttpClient([crate_host], ca_cert=valid_ca_cert)
48
+ >>> verifying_valid_client.server_infos(verifying_valid_client._get_server())
49
+ ('https://localhost:65534', 'test', '0.0.0')
55
50
56
- >>> non_verifying_client = HttpClient([crate_host], ca_cert=invalid_ca_cert, verify_ssl_cert=False)
51
+ When turning off certificate verification, calling the server will succeed::
52
+
53
+ >>> non_verifying_client = HttpClient([crate_host], verify_ssl_cert=False)
57
54
>>> non_verifying_client.server_infos(crate_host)
58
55
('https://localhost:65534', 'test', '0.0.0')
59
56
60
- Connecting to a host whose certificate is verified with a valid CA certificate::
57
+ Without verification, calling the server will even work when using an invalid
58
+ ``ca_cert``::
61
59
62
- >>> verifying_valid_client = HttpClient([crate_host], ca_cert=valid_ca_cert, verify_ssl_cert=True )
63
- >>> verifying_valid_client .server_infos(verifying_valid_client._get_server() )
60
+ >>> non_verifying_client = HttpClient([crate_host], verify_ssl_cert=False, ca_cert=invalid_ca_cert )
61
+ >>> non_verifying_client .server_infos(crate_host )
64
62
('https://localhost:65534', 'test', '0.0.0')
65
63
66
64
67
- Client Certificate
65
+ Client certificate
68
66
------------------
69
67
70
68
The client supports client certificates.
@@ -73,12 +71,11 @@ The ``HttpClient`` constructor takes two keyword arguments: ``cert_file`` and
73
71
``key_file``. Both should be a string pointing to the path of the client
74
72
certificate and key file.
75
73
76
- Below an example, in this case it fails because the supplied certificate is
74
+ This example uses that options, however it fails because the certificate is
77
75
invalid::
78
76
79
- >>> client = HttpClient([crate_host], cert_file=invalid_ca_cert, key_file=invalid_ca_cert, verify_ssl_cert=True )
77
+ >>> client = HttpClient([crate_host], cert_file=invalid_ca_cert, key_file=invalid_ca_cert, timeout=10 )
80
78
>>> client.server_infos(crate_host)
81
79
Traceback (most recent call last):
82
80
...
83
81
crate.client.exceptions.ConnectionError: Server not available, exception: ...[SSL: ...
84
-
0 commit comments