diff --git a/irc/connection.py b/irc/connection.py index 3afe7e5..a0551b9 100644 --- a/irc/connection.py +++ b/irc/connection.py @@ -20,13 +20,16 @@ class Factory: .. code-block:: python + context = ssl.create_default_context() + wrapper = functools.partial(context.wrap_socket, server_hostname=server_address) Factory(wrapper=ssl.wrap_socket)(server_address) To create an SSL connection with parameters to wrap_socket: .. code-block:: python - wrapper = functools.partial(ssl.wrap_socket, ssl_cert=get_cert()) + context = ssl.create_default_context() + wrapper = functools.partial(context.wrap_socket, server_hostname=server_address, ssl_cert=get_cert()) Factory(wrapper=wrapper)(server_address) To create an IPv6 connection: diff --git a/newsfragments/216.feature.rst b/newsfragments/216.feature.rst new file mode 100644 index 0000000..5891dd9 --- /dev/null +++ b/newsfragments/216.feature.rst @@ -0,0 +1 @@ +Replace deprecated ssl.wrap_socket with SSLContext.wrap_socket and update examples in connection.py docs. diff --git a/scripts/ssl-cat.py b/scripts/ssl-cat.py index 7b6400b..00037f8 100644 --- a/scripts/ssl-cat.py +++ b/scripts/ssl-cat.py @@ -11,6 +11,7 @@ import ssl import argparse import itertools +import functools import irc.client @@ -60,7 +61,9 @@ def main(): args = get_args() target = args.target - ssl_factory = irc.connection.Factory(wrapper=ssl.wrap_socket) + context = ssl.create_default_context() + wrapper = functools.partial(context.wrap_socket, server_hostname=args.server) + ssl_factory = irc.connection.Factory(wrapper=wrapper) reactor = irc.client.Reactor() try: c = reactor.server().connect(