Skip to content

Commit 973658c

Browse files
committed
Some adjustments re. switchover to default certificate verification
1 parent 71fb4d8 commit 973658c

File tree

4 files changed

+38
-25
lines changed

4 files changed

+38
-25
lines changed

docs/connect.rst

+10-14
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,26 @@ URL:
100100

101101
>>> connection = client.connect('https://localhost:4200/', ...)
102102

103-
.. CAUTION::
104-
105-
By default, server certificates are *not* verified.
106-
107103
.. SEEALSO::
108104

109105
The CrateDB reference has a section on `setting up SSL`_. This will be
110-
useful background reading for the following two subsections.
106+
a useful background reading for the following two subsections.
111107

112108
Server verification
113109
...................
114110

115-
You can enable server SSL certificate verification by passing in the
116-
``verify_ssl_cert`` keyword argument and setting it to ``True``.
111+
Server certificates are verified by default. In order to connect to a
112+
SSL-enabled host using self-signed certificates, you will need to provide the
113+
CA certificate file used to sign the server SSL certificate::
117114

118-
However, in order to do so, you also need to specify the certificate file of
119-
the *Certificate Authority* (CA) used to sign the server SSL certificate. You
120-
can do this using the ``ca_cert`` keyword argument.
115+
>>> connection = client.connect(..., ca_cert="<CA_CERT_FILE>")
121116

122-
Here's how you might do that::
117+
Here, replace ``<CA_CERT_FILE>`` with the path to the CA certificate file.
123118

124-
>>> connection = client.connect(..., ca_cert="<CA_CERT_FILE>", verify_ssl_cert=True)
119+
You can disable server SSL certificate verification by using the
120+
``verify_ssl_cert`` keyword argument and setting it to ``False``::
125121

126-
Here, replace ``<CA_CERT_FILE>`` with the path to the CA certificate file.
122+
>>> connection = client.connect(..., verify_ssl_cert=False)
127123

128124

129125
Client verification
@@ -148,7 +144,7 @@ Timeout
148144
-------
149145

150146
Connection timeouts (in seconds) can be configured with the optional
151-
``timeout`` argument:
147+
``timeout`` argument::
152148

153149
>>> connection = client.connect(..., timeout=5)
154150

docs/sqlalchemy.rst

+14-6
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,29 @@ the ``connect_args`` argument, like so::
105105
When you do this, the Database API layer will use its :ref:`round-robin
106106
<multiple-nodes>` implementation.
107107

108-
The client validates `SSL server certificates`_ by default. To configure
109-
this behaviour, SSL verification options can be passed in via ``connect_args``
110-
too::
108+
The client validates `SSL server certificates`_ by default. For further
109+
adjusting this behaviour, SSL verification options can be passed in by using
110+
the ``connect_args`` dictionary. For example, use ``ca_cert`` for providing
111+
a path to the CA certificate used for signing the server certificate::
111112

112113
>>> engine = sa.create_engine(
113114
... 'crate://',
114115
... connect_args={
115116
... 'servers': ['198.51.100.1:4200', '198.51.100.2:4200'],
116-
... 'verify_ssl_cert': True,
117117
... 'ca_cert': '<PATH_TO_CA_CERT>',
118118
... }
119119
... )
120120

121-
Here, ``<PATH_TO_CA_CERT>`` should be replaced with the path to the correct CA
122-
certificate.
121+
In order to disable SSL verification, use ``verify_ssl_cert = False``, like::
122+
123+
>>> engine = sa.create_engine(
124+
... 'crate://',
125+
... connect_args={
126+
... 'servers': ['198.51.100.1:4200', '198.51.100.2:4200'],
127+
... 'verify_ssl_cert': False,
128+
... }
129+
... )
130+
123131

124132
Get a session
125133
.............

src/crate/client/connection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(self,
6161
(optional - for testing)
6262
client used to communicate with crate.
6363
:param verify_ssl_cert:
64-
if set to ``True`` verify the servers SSL server certificate.
64+
if set to ``False``, disable SSL server certificate verification.
6565
defaults to ``True``
6666
:param ca_cert:
6767
a path to a CA certificate to use when verifying the SSL server

src/crate/client/doctests/sqlalchemy.txt

+13-4
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,27 @@ The ``connect_args`` parameter has to be used to do so::
3232
... })
3333
Engine(crate://)
3434

35-
As defined in :ref:`https_connection` the client validates SSL server
36-
certificates by default. To configure this behaviour, SSL verification options
37-
can be given via ``connect_args`` too::
35+
As defined in :ref:`https_connection`, the client validates SSL server
36+
certificates by default. To configure this further, use e.g. the ``ca_cert``
37+
attribute within the ``connect_args``, like::
3838

3939
>>> ssl_engine = sa.create_engine(
4040
... 'crate://',
4141
... connect_args={
4242
... 'servers': ['https://host1:4200'],
43-
... 'verify_ssl_cert': True,
4443
... 'ca_cert': '/path/to/cacert.pem',
4544
... })
4645

46+
In order to disable SSL verification, use ``verify_ssl_cert = False``, like::
47+
48+
>>> ssl_engine = sa.create_engine(
49+
... 'crate://',
50+
... connect_args={
51+
... 'servers': ['https://host1:4200'],
52+
... 'verify_ssl_cert': False,
53+
... })
54+
55+
4756
Complex Types
4857
=============
4958

0 commit comments

Comments
 (0)