Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7ffed8

Browse files
committed
Add a subsection explaning cipher selection.
1 parent a12d5c6 commit b7ffed8

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Doc/library/ssl.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,25 @@ SSLv2 explicitly using the :data:`SSLContext.options` attribute::
984984
The SSL context created above will allow SSLv3 and TLSv1 connections, but
985985
not SSLv2.
986986

987+
Cipher selection
988+
^^^^^^^^^^^^^^^^
989+
990+
If you have advanced security requirements, fine-tuning of the ciphers
991+
enabled when negotiating a SSL session is possible through the
992+
:meth:`SSLContext.set_ciphers` method. Starting from Python 3.2.3, the
993+
ssl module disables certain weak ciphers by default, but you may want
994+
to further restrict the cipher choice. For example::
995+
996+
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
997+
context.set_ciphers('HIGH:!aNULL:!eNULL')
998+
999+
The ``!aNULL:!eNULL`` part of the cipher spec is necessary to disable ciphers
1000+
which don't provide both encryption and authentication. Be sure to read
1001+
OpenSSL's documentation about the `cipher list
1002+
format <http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT>`_.
1003+
If you want to check which ciphers are enabled by a given cipher list,
1004+
use the ``openssl ciphers`` command on your system.
1005+
9871006

9881007
.. seealso::
9891008

0 commit comments

Comments
 (0)