Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2280)

Unified Diff: Lib/poplib.py

Issue 19689: ssl.create_default_context()
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/nntplib.py ('k') | Lib/smtplib.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/poplib.py Fri Nov 22 16:20:53 2013 +0100
+++ b/Lib/poplib.py Fri Nov 22 18:04:20 2013 +0100
@@ -385,8 +385,7 @@
if not 'STLS' in caps:
raise error_proto('-ERR STLS not supported by server')
if context is None:
- context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- context.options |= ssl.OP_NO_SSLv2
+ context = ssl.create_default_context()
resp = self._shortcmd('STLS')
self.sock = context.wrap_socket(self.sock)
self.file = self.sock.makefile('rb')
@@ -421,15 +420,15 @@
"exclusive")
self.keyfile = keyfile
self.certfile = certfile
+ if context is None:
+ context = ssl.create_default_context(certfile=certfile,
+ keyfile=keyfile)
self.context = context
POP3.__init__(self, host, port, timeout)
def _create_socket(self, timeout):
sock = POP3._create_socket(self, timeout)
- if self.context is not None:
- sock = self.context.wrap_socket(sock)
- else:
- sock = ssl.wrap_socket(sock, self.keyfile, self.certfile)
+ sock = self.context.wrap_socket(sock)
return sock
def stls(self, keyfile=None, certfile=None, context=None):
« no previous file with comments | « Lib/nntplib.py ('k') | Lib/smtplib.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+