mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-17 05:42:38 -07:00
ssl.wrap_socket() was removed in Python 3.12 (#7542)
* ssl.wrap_socket() was removed in Python 3.12. * Make code for irc module backwards-compatible.
This commit is contained in:
parent
3c12c6f482
commit
21cd65fccf
3 changed files with 15 additions and 9 deletions
|
@ -195,7 +195,14 @@ def send_msg(msg, server='localhost', port='6667', channel=None, nick_to=None, k
|
|||
|
||||
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
if use_ssl:
|
||||
irc = ssl.wrap_socket(irc)
|
||||
if getattr(ssl, 'PROTOCOL_TLS', None) is not None:
|
||||
# Supported since Python 2.7.13
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||
else:
|
||||
context = ssl.SSLContext()
|
||||
context.verify_mode = ssl.CERT_NONE
|
||||
# TODO: create a secure context with `context = ssl.create_default_context()` instead!
|
||||
irc = context.wrap_socket(irc)
|
||||
irc.connect((server, int(port)))
|
||||
|
||||
if passwd:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue