Skip to content

Commit d8abb4b

Browse files
committed
Improve Atlas and TLS documentation
1 parent 958642f commit d8abb4b

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

doc/atlas.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@ dependencies using the following pip command::
1717
Earlier versions of PyMongo require you to manually install the dependencies.
1818
For a list of TLS/SSL-related dependencies, see :doc:`examples/tls`.
1919

20-
.. warning:: Industry best practices, and some regulations, require the use
21-
of TLS 1.1 or newer. Though no application changes are required for
20+
.. note:: Connecting to Atlas "Free Tier" or "Shared Cluster" instances
21+
requires Server Name Indication (SNI) support. SNI support requires CPython
22+
2.7.9 / PyPy 2.5.1 or newer. To check if your version of Python supports
23+
SNI run the following command::
24+
25+
$ python -c "import ssl; print(getattr(ssl, 'HAS_SNI', False))"
26+
27+
You should see "True".
28+
29+
.. warning:: Industry best practices recommend, and some regulations require,
30+
the use of TLS 1.1 or newer. Though no application changes are required for
2231
PyMongo to make use of the newest protocols, some operating systems or
2332
versions may not provide an OpenSSL version new enough to support them.
2433

doc/examples/tls.rst

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ On Windows, the `wincertstore`_ module is required when using PyPy3 < 3.5.
3636
.. _wincertstore: https://pypi.python.org/pypi/wincertstore
3737
.. _certifi: https://pypi.python.org/pypi/certifi
3838

39-
.. warning:: Industry best practices, and some regulations, require the use
40-
of TLS 1.1 or newer. Though no application changes are required for
39+
.. warning:: Industry best practices recommend, and some regulations require,
40+
the use of TLS 1.1 or newer. Though no application changes are required for
4141
PyMongo to make use of the newest protocols, some operating systems or
4242
versions may not provide an OpenSSL version new enough to support them.
4343

@@ -165,3 +165,42 @@ to decrypt encrypted private keys. Use the `ssl_pem_passphrase` option::
165165

166166

167167
These options can also be passed as part of the MongoDB URI.
168+
169+
Troubleshooting TLS Errors
170+
..........................
171+
172+
TLS errors often fall into two categories, certificate verification failure or
173+
protocol version mismatch. An error message similar to the following means that
174+
OpenSSL was not able to verify the server's certificate::
175+
176+
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
177+
178+
This often occurs because OpenSSL does not have access to the system's
179+
root certificates or the certificates are out of date. Linux users should
180+
ensure that they have the latest root certificate updates installed from
181+
their Linux vendor. macOS users using Python 3.6.0 or newer downloaded
182+
from python.org `may have to run a script included with python
183+
<https://bugs.python.org/issue29065#msg283984>`_ to install
184+
root certificates::
185+
186+
open "/Applications/Python <YOUR PYTHON VERSION>/Install Certificates.command"
187+
188+
Users of older PyPy and PyPy3 portable versions may have to `set an environment
189+
variable <https://github.com/squeaky-pl/portable-pypy/issues/15>`_ to tell
190+
OpenSSL where to find root certificates. This is easily done using the `certifi
191+
module <https://pypi.org/project/certifi/>`_ from pypi::
192+
193+
$ pypy -m pip install certifi
194+
$ export SSL_CERT_FILE=$(pypy -c "import certifi; print(certifi.where())")
195+
196+
An error message similar to the following message means that the OpenSSL
197+
version used by Python does not support a new enough TLS protocol to connect
198+
to the server::
199+
200+
[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version
201+
202+
Industry best practices recommend, and some regulations require, that older
203+
TLS protocols be disabled in some MongoDB deployments. Some deployments may
204+
disable TLS 1.0, others may disable TLS 1.0 and TLS 1.1. See the warning
205+
earlier in this document for troubleshooting steps and solutions.
206+

0 commit comments

Comments
 (0)