Skip to content

Commit bce5f95

Browse files
committed
Don't promote the use of ssl.CERT_OPTIONAL
1 parent aef97ae commit bce5f95

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

doc/examples/tls.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ Or, in the URI::
5151
>>> uri = 'mongodb://example.com/?ssl=true&ssl_cert_reqs=CERT_NONE'
5252
>>> client = pymongo.MongoClient(uri)
5353

54-
You can also configure optional certificate verification, if a certificate is
55-
provided by the server::
56-
57-
>>> import ssl
58-
>>> client = pymongo.MongoClient('example.com',
59-
... ssl=True,
60-
... ssl_cert_reqs=ssl.CERT_OPTIONAL)
61-
>>>
62-
>>> uri = 'mongodb://example.com/?ssl=true&ssl_cert_reqs=CERT_OPTIONAL'
63-
>>> client = pymongo.MongoClient(uri)
64-
6554
Specifying a CA file
6655
....................
6756

pymongo/mongo_client.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,15 @@ def __init__(
217217
- `ssl_cert_reqs`: Specifies whether a certificate is required from
218218
the other side of the connection, and whether it will be validated
219219
if provided. It must be one of the three values ``ssl.CERT_NONE``
220-
(certificates ignored), ``ssl.CERT_OPTIONAL``
221-
(not required, but validated if provided), or ``ssl.CERT_REQUIRED``
222-
(required and validated). If the value of this parameter is not
223-
``ssl.CERT_NONE`` and a value is not provided for ``ssl_ca_certs``
224-
PyMongo will attempt to load system provided CA certificates.
225-
If the python version in use does not support loading system CA
226-
certificates then the ``ssl_ca_certs`` parameter must point
227-
to a file of CA certificates. Implies ``ssl=True``. Defaults to
220+
(certificates ignored), ``ssl.CERT_REQUIRED`` (certificates
221+
required and validated), or ``ssl.CERT_OPTIONAL`` (the same as
222+
CERT_REQUIRED, unless the server was configured to use anonymous
223+
ciphers). If the value of this parameter is not ``ssl.CERT_NONE``
224+
and a value is not provided for ``ssl_ca_certs`` PyMongo will
225+
attempt to load system provided CA certificates. If the python
226+
version in use does not support loading system CA certificates
227+
then the ``ssl_ca_certs`` parameter must point to a file of CA
228+
certificates. Implies ``ssl=True``. Defaults to
228229
``ssl.CERT_REQUIRED`` if not provided and ``ssl=True``.
229230
- `ssl_ca_certs`: The ca_certs file contains a set of concatenated
230231
"certification authority" certificates, which are used to validate

0 commit comments

Comments
 (0)