From 5b745c377896d8e952b60aabbc47f2e5f1190574 Mon Sep 17 00:00:00 2001 From: Hans Becker <2929278+StareInTheAir@users.noreply.github.com> Date: Mon, 25 Dec 2023 12:02:18 +0100 Subject: [PATCH 1/2] Replace deprecated ssl.wrap_socket with SSLContext.wrap_socket Update examples in connection.py docs --- irc/connection.py | 5 ++++- scripts/ssl-cat.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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/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( From 52aac1ba6cde1a62ae5a9c7770be07f3b032b60d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 28 Mar 2024 09:07:39 -0400 Subject: [PATCH 2/2] Add news fragment. --- newsfragments/216.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/216.feature.rst 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.