MCPcopy Index your code
hub / github.com/python/cpython / test_default_ecdh_curve

Method test_default_ecdh_curve

Lib/test/test_ssl.py:4267–4282  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4265 self.assertEqual(s.version(), 'SSLv3')
4266
4267 def test_default_ecdh_curve(self):
4268 # Issue #21015: elliptic curve-based Diffie Hellman key exchange
4269 # should be enabled by default on SSL contexts.
4270 client_context, server_context, hostname = testing_context()
4271 # TLSv1.3 defaults to PFS key agreement and no longer has KEA in
4272 # cipher name.
4273 client_context.maximum_version = ssl.TLSVersion.TLSv1_2
4274 # Prior to OpenSSL 1.0.0, ECDH ciphers have to be enabled
4275 # explicitly using the 'ECCdraft' cipher alias. Otherwise,
4276 # our default cipher list should prefer ECDH-based ciphers
4277 # automatically.
4278 with ThreadedEchoServer(context=server_context) as server:
4279 with client_context.wrap_socket(socket.socket(),
4280 server_hostname=hostname) as s:
4281 s.connect((HOST, server.port))
4282 self.assertIn("ECDH", s.cipher()[0])
4283
4284 @unittest.skipUnless("tls-unique" in ssl.CHANNEL_BINDING_TYPES,
4285 "'tls-unique' channel binding not available")

Callers

nothing calls this directly

Calls 7

testing_contextFunction · 0.85
ThreadedEchoServerClass · 0.85
wrap_socketMethod · 0.80
socketMethod · 0.80
assertInMethod · 0.80
connectMethod · 0.45
cipherMethod · 0.45

Tested by

no test coverage detected