Skip to content

Commit d46bd16

Browse files
committed
PYTHON-2093 Documentation for OCSP
1 parent 8e5dbc9 commit d46bd16

File tree

5 files changed

+98
-9
lines changed

5 files changed

+98
-9
lines changed

README.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ PyMongo::
113113

114114
$ python -m pip install pymongo[tls]
115115

116+
.. note:: Users of Python versions older than 2.7.9 will also
117+
receive the dependencies for OCSP when using the tls extra.
118+
119+
:ref:`OCSP` requires `PyOpenSSL
120+
<https://pypi.org/project/pyOpenSSL/>`_, `requests
121+
<https://pypi.org/project/requests/>`_ and `service_identity
122+
<https://pypi.org/project/service_identity/>`_::
123+
124+
$ python -m pip install pymongo[ocsp]
125+
116126
Wire protocol compression with snappy requires `python-snappy
117127
<https://pypi.org/project/python-snappy>`_::
118128

@@ -126,7 +136,7 @@ Wire protocol compression with zstandard requires `zstandard
126136
You can install all dependencies automatically with the following
127137
command::
128138

129-
$ python -m pip install pymongo[snappy,gssapi,srv,tls,zstd]
139+
$ python -m pip install pymongo[gssapi,ocsp,snappy,srv,tls,zstd]
130140

131141
Other optional packages:
132142

doc/atlas.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ dependencies using the following pip command::
1414

1515
$ python -m pip install pymongo[tls]
1616

17+
Starting with PyMongo 3.11 this installs `PyOpenSSL
18+
<https://pypi.org/project/pyOpenSSL/>`_, `requests`_
19+
and `service_identity
20+
<https://pypi.org/project/service_identity/>`_
21+
for users of Python versions older than 2.7.9. PyOpenSSL supports SNI for these
22+
old Python versions, allowing applictions to connect to Altas free and shared
23+
tier instances.
24+
1725
Earlier versions of PyMongo require you to manually install the dependencies.
1826
For a list of TLS/SSL-related dependencies, see :doc:`examples/tls`.
1927

2028
.. note:: Connecting to Atlas "Free Tier" or "Shared Cluster" instances
2129
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::
30+
2.7.9 / PyPy 2.5.1 or newer or PyMongo 3.11+ with PyOpenSSL.
31+
To check if your version of Python supports SNI run the following command::
2432

2533
$ python -c "import ssl; print(getattr(ssl, 'HAS_SNI', False))"
2634

doc/changelog.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
Changelog
22
=========
33

4+
Changes in Version 3.11.0
5+
-------------------------
6+
7+
Version 3.11 adds support for MongoDB 4.4. Highlights include:
8+
9+
- Support for :ref:`OCSP` (Online Certificate Status Protocol)
10+
- Support for `PyOpenSSL <https://pypi.org/project/pyOpenSSL/>`_ as an
11+
alternative TLS implementation. PyOpenSSL is required for :ref:`OCSP`
12+
support. It will also be installed when using the "tls" extra if the
13+
version of Python in use is older than 2.7.9.
14+
15+
Issues Resolved
16+
...............
17+
18+
See the `PyMongo 3.11.0 release notes in JIRA`_ for the list of resolved issues
19+
in this release.
20+
21+
.. _PyMongo 3.11.0 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=24799
22+
423
Changes in Version 3.10.1
524
-------------------------
625

doc/examples/tls.rst

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ command::
1616

1717
$ python -m pip install pymongo[tls]
1818

19+
Starting with PyMongo 3.11 this installs `PyOpenSSL
20+
<https://pypi.org/project/pyOpenSSL/>`_, `requests`_
21+
and `service_identity
22+
<https://pypi.org/project/service_identity/>`_
23+
for users of Python versions older than 2.7.9. PyOpenSSL supports SNI for these
24+
old Python versions allowing applictions to connect to Altas free and shared
25+
tier instances.
26+
1927
Earlier versions of PyMongo require you to manually install the dependencies
2028
listed below.
2129

@@ -103,8 +111,9 @@ Specifying a CA file
103111
....................
104112

105113
In some cases you may want to configure PyMongo to use a specific set of CA
106-
certificates. This is most often the case when using "self-signed" server
107-
certificates. The `ssl_ca_certs` option takes a path to a CA file. It can be
114+
certificates. This is most often the case when you are acting as your own
115+
certificate authority rather than using server certificates signed by a well
116+
known authority. The `ssl_ca_certs` option takes a path to a CA file. It can be
108117
passed as a keyword argument::
109118

110119
>>> client = pymongo.MongoClient('example.com',
@@ -132,6 +141,8 @@ Or, in the URI::
132141
>>> uri = 'mongodb://example.com/?ssl=true&ssl_crlfile=/path/to/crl.pem'
133142
>>> client = pymongo.MongoClient(uri)
134143

144+
.. note:: Certificate revocation lists and :ref:`OCSP` cannot be used together.
145+
135146
Client certificates
136147
...................
137148

@@ -162,12 +173,37 @@ to decrypt encrypted private keys. Use the `ssl_pem_passphrase` option::
162173

163174
These options can also be passed as part of the MongoDB URI.
164175

176+
.. _OCSP:
177+
178+
OCSP
179+
....
180+
181+
Starting with PyMongo 3.11, if PyMongo was installed with the "ocsp" extra::
182+
183+
python -m pip install pymongo[ocsp]
184+
185+
certificate revocation checking is enabled by way of `OCSP (Online Certification
186+
Status Protocol) <https://en.wikipedia.org/wiki/Online_Certificate_Status_Protocol>`_.
187+
MongoDB 4.4+ `staples OCSP responses <https://en.wikipedia.org/wiki/OCSP_stapling>`_
188+
to the TLS handshake which PyMongo will verify, failing the TLS handshake if
189+
the stapled OCSP response is invalid or indicates that the peer certificate is
190+
revoked.
191+
192+
When connecting to a server version older than 4.4, or when a 4.4+ version of
193+
MongoDB does not staple an OCSP response, PyMongo will attempt to connect
194+
directly to an OCSP endpoint if the peer certificate specified one. The TLS
195+
handshake will only fail in this case if the response indicates that the
196+
certificate is revoked. Invalid or malformed responses will be ignored,
197+
favoring availability over maximum security.
198+
199+
165200
Troubleshooting TLS Errors
166201
..........................
167202

168-
TLS errors often fall into two categories, certificate verification failure or
169-
protocol version mismatch. An error message similar to the following means that
170-
OpenSSL was not able to verify the server's certificate::
203+
TLS errors often fall into three categories - certificate verification failure,
204+
protocol version mismatch or certificate revocation checking failure. An error
205+
message similar to the following means that OpenSSL was not able to verify the
206+
server's certificate::
171207

172208
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
173209

@@ -200,3 +236,9 @@ TLS protocols be disabled in some MongoDB deployments. Some deployments may
200236
disable TLS 1.0, others may disable TLS 1.0 and TLS 1.1. See the warning
201237
earlier in this document for troubleshooting steps and solutions.
202238

239+
An error message similar to the following message means that certificate
240+
revocation checking failed::
241+
242+
[('SSL routines', 'tls_process_initial_server_flight', 'invalid status response')]
243+
244+
See :ref:`OCSP` for more details.

doc/installation.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ PyMongo::
7070

7171
$ python -m pip install pymongo[tls]
7272

73+
.. note:: Users of Python versions older than 2.7.9 will also
74+
receive the dependencies for OCSP when using the tls extra.
75+
76+
:ref:`OCSP` requires `PyOpenSSL
77+
<https://pypi.org/project/pyOpenSSL/>`_, `requests
78+
<https://pypi.org/project/requests/>`_ and `service_identity
79+
<https://pypi.org/project/service_identity/>`_::
80+
81+
$ python -m pip install pymongo[ocsp]
82+
7383
Wire protocol compression with snappy requires `python-snappy
7484
<https://pypi.org/project/python-snappy>`_::
7585

@@ -83,7 +93,7 @@ Wire protocol compression with zstandard requires `zstandard
8393
You can install all dependencies automatically with the following
8494
command::
8595

86-
$ python -m pip install pymongo[snappy,gssapi,srv,tls,zstd]
96+
$ python -m pip install pymongo[gssapi,ocsp,snappy,srv,tls,zstd]
8797

8898
Other optional packages:
8999

0 commit comments

Comments
 (0)