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

Skip to content

Commit 6db4944

Browse files
committed
Issue #13635: Add ssl.OP_CIPHER_SERVER_PREFERENCE, so that SSL servers
choose the cipher based on their own preferences, rather than on the client's.
1 parent bfaa79a commit 6db4944

5 files changed

Lines changed: 18 additions & 1 deletion

File tree

Doc/library/ssl.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,13 @@ Constants
421421

422422
.. versionadded:: 3.2
423423

424+
.. data:: OP_CIPHER_SERVER_PREFERENCE
425+
426+
Use the server's cipher ordering preference, rather than the client's.
427+
This option has no effect on client sockets and SSLv2 server sockets.
428+
429+
.. versionadded:: 3.3
430+
424431
.. data:: HAS_SNI
425432

426433
Whether the OpenSSL library has built-in support for the *Server Name

Lib/ssl.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@
6666
SSLSyscallError, SSLEOFError,
6767
)
6868
from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
69-
from _ssl import OP_ALL, OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1
69+
from _ssl import (
70+
OP_ALL, OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1,
71+
OP_CIPHER_SERVER_PREFERENCE,
72+
)
7073
from _ssl import RAND_status, RAND_egd, RAND_add, RAND_bytes, RAND_pseudo_bytes
7174
from _ssl import (
7275
SSL_ERROR_ZERO_RETURN,

Lib/test/test_ssl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def test_constants(self):
9898
ssl.CERT_NONE
9999
ssl.CERT_OPTIONAL
100100
ssl.CERT_REQUIRED
101+
ssl.OP_CIPHER_SERVER_PREFERENCE
101102
self.assertIn(ssl.HAS_SNI, {True, False})
102103

103104
def test_random(self):

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,10 @@ Core and Builtins
419419
Library
420420
-------
421421

422+
- Issue #13635: Add ssl.OP_CIPHER_SERVER_PREFERENCE, so that SSL servers
423+
choose the cipher based on their own preferences, rather than on the
424+
client's.
425+
422426
- Issue #11813: Fix inspect.getattr_static for modules. Patch by Andreas
423427
Stührk.
424428

Modules/_ssl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,6 +2450,8 @@ PyInit__ssl(void)
24502450
PyModule_AddIntConstant(m, "OP_NO_SSLv2", SSL_OP_NO_SSLv2);
24512451
PyModule_AddIntConstant(m, "OP_NO_SSLv3", SSL_OP_NO_SSLv3);
24522452
PyModule_AddIntConstant(m, "OP_NO_TLSv1", SSL_OP_NO_TLSv1);
2453+
PyModule_AddIntConstant(m, "OP_CIPHER_SERVER_PREFERENCE",
2454+
SSL_OP_CIPHER_SERVER_PREFERENCE);
24532455

24542456
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
24552457
r = Py_True;

0 commit comments

Comments
 (0)