summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/selector_events.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-10-15 14:58:21 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-10-15 14:58:21 (GMT)
commitfd39a89e0e09de5460626a68e9e443fe0c103c14 (patch)
tree69f3e067853b0f27e722b44ed3e05c79751dce5f /Lib/asyncio/selector_events.py
parent7184bac5446aefcf576bc8a0a666cfd096b86293 (diff)
downloadcpython-fd39a89e0e09de5460626a68e9e443fe0c103c14.zip
cpython-fd39a89e0e09de5460626a68e9e443fe0c103c14.tar.gz
cpython-fd39a89e0e09de5460626a68e9e443fe0c103c14.tar.bz2
Issue #22641: In asyncio, the default SSL context for client connections is now created using ssl.create_default_context(), for stronger security.
Diffstat (limited to 'Lib/asyncio/selector_events.py')
-rw-r--r--Lib/asyncio/selector_events.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index a55eff7..c5debf8 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -689,16 +689,17 @@ class _SelectorSslTransport(_SelectorTransport):
if not sslcontext:
# Client side may pass ssl=True to use a default
# context; in that case the sslcontext passed is None.
- # The default is the same as used by urllib with
- # cadefault=True.
- if hasattr(ssl, '_create_stdlib_context'):
- sslcontext = ssl._create_stdlib_context(
- cert_reqs=ssl.CERT_REQUIRED,
- check_hostname=bool(server_hostname))
+ # The default is secure for client connections.
+ if hasattr(ssl, 'create_default_context'):
+ # Python 3.4+: use up-to-date strong settings.
+ sslcontext = ssl.create_default_context()
+ if not server_hostname:
+ sslcontext.check_hostname = False
else:
# Fallback for Python 3.3.
sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
sslcontext.options |= ssl.OP_NO_SSLv2
+ sslcontext.options |= ssl.OP_NO_SSLv3
sslcontext.set_default_verify_paths()
sslcontext.verify_mode = ssl.CERT_REQUIRED