Skip to content

Commit

Permalink
Remove SSL compatibility code for Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Menno Finlay-Smits committed Oct 27, 2023
1 parent 5db7671 commit 41e65f5
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions imapclient/tls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015, Menno Smits
# Copyright (c) 2023, Menno Smits
# Released subject to the New BSD License
# Please see http://en.wikipedia.org/wiki/BSD_licenses

Expand All @@ -20,18 +20,6 @@
def wrap_socket(
sock: socket.socket, ssl_context: Optional[ssl.SSLContext], host: str
) -> socket.socket:
if not hasattr(ssl, "create_default_context"):
# Python 2.7.0 - 2.7.8 do not have the concept of ssl contexts.
# Thus we have to use the less flexible and legacy way of wrapping the
# socket
if ssl_context is not None:
raise RuntimeError(
"Cannot precisely configure the SSL connection, upgrade to "
"Python >= 2.7.9 to fine tune the settings."
)

return ssl.wrap_socket(sock)

if ssl_context is None:
ssl_context = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)

Expand Down

0 comments on commit 41e65f5

Please sign in to comment.