Skip to content

Commit e8eb6cb

Browse files
authored
bpo-33570: TLS 1.3 ciphers for OpenSSL 1.1.1 (GH-6976)
Change TLS 1.3 cipher suite settings for compatibility with OpenSSL 1.1.1-pre6 and newer. OpenSSL 1.1.1 will have TLS 1.3 cipers enabled by default. Also update multissltests and Travis config to test with latest OpenSSL. Signed-off-by: Christian Heimes <[email protected]>
1 parent 6c4fab0 commit e8eb6cb

File tree

5 files changed

+33
-39
lines changed

5 files changed

+33
-39
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cache:
1212

1313
env:
1414
global:
15-
- OPENSSL=1.1.0g
15+
- OPENSSL=1.1.0h
1616
- OPENSSL_DIR="$HOME/multissl/openssl/${OPENSSL}"
1717
- PATH="${OPENSSL_DIR}/bin:$PATH"
1818
# Use -O3 because we don't use debugger on Travis-CI

Doc/library/ssl.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ purposes.
169169

170170
3DES was dropped from the default cipher string.
171171

172-
.. versionchanged:: 3.7
173-
174-
TLS 1.3 cipher suites TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384,
175-
and TLS_CHACHA20_POLY1305_SHA256 were added to the default cipher string.
176-
177172

178173
Exceptions
179174
^^^^^^^^^^
@@ -1601,6 +1596,9 @@ to speed up repeated connections from the same clients.
16011596
when connected, the :meth:`SSLSocket.cipher` method of SSL sockets will
16021597
give the currently selected cipher.
16031598

1599+
OpenSSL 1.1.1 has TLS 1.3 cipher suites enabled by default. The suites
1600+
cannot be disabled with :meth:`~SSLContext.set_ciphers`.
1601+
16041602
.. method:: SSLContext.set_alpn_protocols(protocols)
16051603

16061604
Specify which protocols the socket should advertise during the SSL/TLS

Lib/test/test_ssl.py

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,10 +2695,7 @@ def test_check_hostname(self):
26952695
def test_ecc_cert(self):
26962696
client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
26972697
client_context.load_verify_locations(SIGNING_CA)
2698-
client_context.set_ciphers(
2699-
'TLS13-AES-128-GCM-SHA256:TLS13-CHACHA20-POLY1305-SHA256:'
2700-
'ECDHE:ECDSA:!NULL:!aRSA'
2701-
)
2698+
client_context.set_ciphers('ECDHE:ECDSA:!NULL:!aRSA')
27022699
hostname = SIGNED_CERTFILE_ECC_HOSTNAME
27032700

27042701
server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
@@ -3439,17 +3436,16 @@ def test_do_handshake_enotconn(self):
34393436
sock.do_handshake()
34403437
self.assertEqual(cm.exception.errno, errno.ENOTCONN)
34413438

3442-
def test_default_ciphers(self):
3443-
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
3444-
try:
3445-
# Force a set of weak ciphers on our client context
3446-
context.set_ciphers("DES")
3447-
except ssl.SSLError:
3448-
self.skipTest("no DES cipher available")
3449-
with ThreadedEchoServer(CERTFILE,
3450-
ssl_version=ssl.PROTOCOL_TLS,
3451-
chatty=False) as server:
3452-
with context.wrap_socket(socket.socket()) as s:
3439+
def test_no_shared_ciphers(self):
3440+
client_context, server_context, hostname = testing_context()
3441+
# OpenSSL enables all TLS 1.3 ciphers, enforce TLS 1.2 for test
3442+
client_context.options |= ssl.OP_NO_TLSv1_3
3443+
# Force different suites on client and master
3444+
client_context.set_ciphers("AES128")
3445+
server_context.set_ciphers("AES256")
3446+
with ThreadedEchoServer(context=server_context) as server:
3447+
with client_context.wrap_socket(socket.socket(),
3448+
server_hostname=hostname) as s:
34533449
with self.assertRaises(OSError):
34543450
s.connect((HOST, server.port))
34553451
self.assertIn("no shared cipher", server.conn_errors[0])
@@ -3490,9 +3486,9 @@ def test_tls1_3(self):
34903486
with context.wrap_socket(socket.socket()) as s:
34913487
s.connect((HOST, server.port))
34923488
self.assertIn(s.cipher()[0], {
3493-
'TLS13-AES-256-GCM-SHA384',
3494-
'TLS13-CHACHA20-POLY1305-SHA256',
3495-
'TLS13-AES-128-GCM-SHA256',
3489+
'TLS_AES_256_GCM_SHA384',
3490+
'TLS_CHACHA20_POLY1305_SHA256',
3491+
'TLS_AES_128_GCM_SHA256',
34963492
})
34973493
self.assertEqual(s.version(), 'TLSv1.3')
34983494

@@ -3898,23 +3894,20 @@ def cb_wrong_return_type(ssl_sock, server_name, initial_context):
38983894

38993895
def test_shared_ciphers(self):
39003896
client_context, server_context, hostname = testing_context()
3901-
if ssl.OPENSSL_VERSION_INFO >= (1, 0, 2):
3902-
client_context.set_ciphers("AES128:AES256")
3903-
server_context.set_ciphers("AES256")
3904-
alg1 = "AES256"
3905-
alg2 = "AES-256"
3906-
else:
3907-
client_context.set_ciphers("AES:3DES")
3908-
server_context.set_ciphers("3DES")
3909-
alg1 = "3DES"
3910-
alg2 = "DES-CBC3"
3897+
client_context.set_ciphers("AES128:AES256")
3898+
server_context.set_ciphers("AES256")
3899+
expected_algs = [
3900+
"AES256", "AES-256",
3901+
# TLS 1.3 ciphers are always enabled
3902+
"TLS_CHACHA20", "TLS_AES",
3903+
]
39113904

39123905
stats = server_params_test(client_context, server_context,
39133906
sni_name=hostname)
39143907
ciphers = stats['server_shared_ciphers'][0]
39153908
self.assertGreater(len(ciphers), 0)
39163909
for name, tls_version, bits in ciphers:
3917-
if not alg1 in name.split("-") and alg2 not in name:
3910+
if not any(alg in name for alg in expected_algs):
39183911
self.fail(name)
39193912

39203913
def test_read_write_after_close_raises_valuerror(self):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Change TLS 1.3 cipher suite settings for compatibility with OpenSSL
2+
1.1.1-pre6 and newer. OpenSSL 1.1.1 will have TLS 1.3 cipers enabled by
3+
default.

Tools/ssl/multissltests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@
4545
]
4646

4747
OPENSSL_RECENT_VERSIONS = [
48-
"1.0.2n",
49-
"1.1.0g",
50-
"1.1.1-pre1",
48+
"1.0.2o",
49+
"1.1.0h",
50+
"1.1.1-pre6",
5151
]
5252

5353
LIBRESSL_OLD_VERSIONS = [
5454
]
5555

5656
LIBRESSL_RECENT_VERSIONS = [
57-
"2.7.1",
57+
"2.7.3",
5858
]
5959

6060
# store files in ../multissl

0 commit comments

Comments
 (0)