summaryrefslogtreecommitdiffstats
path: root/Lib/imaplib.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-11-23 21:43:47 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-11-23 21:43:47 (GMT)
commit67986f94311ffb46fe5b3efce74d749029041b73 (patch)
tree70aeabba17581022cb3dfcd1c9a59a284a0c1bca /Lib/imaplib.py
parent32eddc1bbc47479a3639b9191ffc82a52903c5f4 (diff)
downloadcpython-67986f94311ffb46fe5b3efce74d749029041b73.zip
cpython-67986f94311ffb46fe5b3efce74d749029041b73.tar.gz
cpython-67986f94311ffb46fe5b3efce74d749029041b73.tar.bz2
Issue #19735: Implement private function ssl._create_stdlib_context() to
create SSLContext objects in Python's stdlib module. It provides a single configuration point and makes use of SSLContext.load_default_certs().
Diffstat (limited to 'Lib/imaplib.py')
-rw-r--r--Lib/imaplib.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index b29487a..dabf161 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -742,9 +742,7 @@ class IMAP4:
raise self.abort('TLS not supported by server')
# Generate a default SSL context if none was passed.
if ssl_context is None:
- ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- # SSLv2 considered harmful.
- ssl_context.options |= ssl.OP_NO_SSLv2
+ ssl_context = ssl._create_stdlib_context()
typ, dat = self._simple_command(name)
if typ == 'OK':
self.sock = ssl_context.wrap_socket(self.sock)
@@ -1210,15 +1208,15 @@ if HAVE_SSL:
self.keyfile = keyfile
self.certfile = certfile
+ if ssl_context is None:
+ ssl_context = ssl._create_stdlib_context(certfile=certfile,
+ keyfile=keyfile)
self.ssl_context = ssl_context
IMAP4.__init__(self, host, port)
def _create_socket(self):
sock = IMAP4._create_socket(self)
- if self.ssl_context:
- return self.ssl_context.wrap_socket(sock)
- else:
- return ssl.wrap_socket(sock, self.keyfile, self.certfile)
+ return self.ssl_context.wrap_socket(sock)
def open(self, host='', port=IMAP4_SSL_PORT):
"""Setup connection to remote server on "host:port".