summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-21 09:56:06 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-21 09:56:06 (GMT)
commitb52187710e4b486b33624fbde9ba646bc8e925fc (patch)
tree3f1c6369c64536edc721855273a793339a0fba9f /Doc/library
parent955d1b22e2b7c1e42a23565e29ba150f1fc9a0ef (diff)
downloadcpython-b52187710e4b486b33624fbde9ba646bc8e925fc.zip
cpython-b52187710e4b486b33624fbde9ba646bc8e925fc.tar.gz
cpython-b52187710e4b486b33624fbde9ba646bc8e925fc.tar.bz2
Issue #4870: Add an `options` attribute to SSL contexts, as well as
several ``OP_*`` constants to the `ssl` module. This allows to selectively disable protocol versions, when used in combination with `PROTOCOL_SSLv23`.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/ssl.rst56
1 files changed, 56 insertions, 0 deletions
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index 45ffcb0..d2f44a1 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -257,6 +257,37 @@ Functions, Constants, and Exceptions
modern version, and probably the best choice for maximum protection, if both
sides can speak it.
+.. data:: OP_ALL
+
+ Enables workarounds for various bugs present in other SSL implementations.
+ This option is set by default.
+
+ .. versionadded:: 3.2
+
+.. data:: OP_NO_SSLv2
+
+ Prevents an SSLv2 connection. This option is only applicable in
+ conjunction with :const:`PROTOCOL_SSLv23`. It prevents the peers from
+ choosing SSLv2 as the protocol version.
+
+ .. versionadded:: 3.2
+
+.. data:: OP_NO_SSLv3
+
+ Prevents an SSLv3 connection. This option is only applicable in
+ conjunction with :const:`PROTOCOL_SSLv23`. It prevents the peers from
+ choosing SSLv3 as the protocol version.
+
+ .. versionadded:: 3.2
+
+.. data:: OP_NO_TLSv1
+
+ Prevents a TLSv1 connection. This option is only applicable in
+ conjunction with :const:`PROTOCOL_SSLv23`. It prevents the peers from
+ choosing TLSv1 as the protocol version.
+
+ .. versionadded:: 3.2
+
.. data:: OPENSSL_VERSION
The version string of the OpenSSL library loaded by the interpreter::
@@ -440,6 +471,17 @@ SSL Contexts
and *suppress_ragged_eofs* have the same meaning as in the top-level
:func:`wrap_socket` function.
+.. attribute:: SSLContext.options
+
+ An integer representing the set of SSL options enabled on this context.
+ The default value is :data:`OP_ALL`, but you can specify other options
+ such as :data:`OP_NO_SSLv2` by ORing them together.
+
+ .. note::
+ With versions of OpenSSL older than 0.9.8m, it is only possible
+ to set options, not to clear them. Attempting to clear an option
+ (by resetting the corresponding bits) will raise a ``ValueError``.
+
.. attribute:: SSLContext.protocol
The protocol version chosen when constructing the context. This attribute
@@ -794,6 +836,20 @@ to specify :const:`CERT_REQUIRED` and similarly check the client certificate.
equivalent unless anonymous ciphers are enabled (they are disabled
by default).
+Protocol versions
+^^^^^^^^^^^^^^^^^
+
+SSL version 2 is considered insecure and is therefore dangerous to use. If
+you want maximum compatibility between clients and servers, it is recommended
+to use :const:`PROTOCOL_SSLv23` as the protocol version and then disable
+SSLv2 explicitly using the :data:`SSLContext.options` attribute::
+
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.options |= ssl.OP_NO_SSLv2
+
+The SSL context created above will allow SSLv3 and TLSv1 connections, but
+not SSLv2.
+
.. seealso::