Skip to content

Commit

Permalink
Fix deprecated ssl.wrap_socket
Browse files Browse the repository at this point in the history
This fix was originally provided by Lalufu in #fedora-devel, and posted
on the issue tracker by @knurd.
  • Loading branch information
bryango committed May 24, 2024
1 parent 2f317af commit 23b689f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Mailnag/common/imaplib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def __init__(self, host=None, port=None, debug=None, debug_file=None, identifier
self.compressor = None # COMPRESS/DEFLATE if not None
self.decompressor = None
self._tls_established = False
self._ssl_context = None

# Create unique tag for this session,
# and compile tagged response matcher.
Expand Down Expand Up @@ -492,7 +493,13 @@ def ssl_wrap_socket(self):

ssl_version = TLS_MAP[self.tls_level][self.ssl_version]

self.sock = ssl.wrap_socket(self.sock, self.keyfile, self.certfile, ca_certs=self.ca_certs, cert_reqs=cert_reqs, ssl_version=ssl_version, ciphers='ALL')
self._ssl_context = ssl.SSLContext(ssl_version)
self._ssl_context.verify_mode = cert_reqs
if self.ca_certs:
self._ssl_context.load_verify_locations(self.ca_certs)
if self.keyfile and self.certfile:
self._ssl_context.load_cert_chain(self.certfile, self.keyfile)
self.sock = self._ssl_context.wrap_socket(self.sock, server_hostname=self.host)
ssl_exc = ssl.SSLError
self.read_fd = self.sock.fileno()
except ImportError:
Expand Down

0 comments on commit 23b689f

Please sign in to comment.