Skip to content

Commit

Permalink
trying to fix ssl socket issues, updated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDoee committed Feb 17, 2024
1 parent 052275e commit 3d10cf0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Changelog
================================

Version 1.10.1 (17-02-2024)
--------------------------------

* Added: Configurable timeout support #42

* Bugfix: Bug related to hanging sockets #42
* Bugfix: Trying to fix cipher issues with ssl socket #44
* Bugfix: Issue with how the new ssl context is used after merging #45

Version 1.10.0 (15-02-2024)
--------------------------------

Expand Down
22 changes: 13 additions & 9 deletions deluge_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,20 @@ def __init__(self, host, port, username, password, decode_utf8=False, automatic_
self.request_id = 1
self.connected = False

# Insecure context without remote certificate verification
self._ssl_context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
self._ssl_context.check_hostname = False
self._ssl_context.verify_mode = ssl.CERT_NONE

self._create_socket()
def _create_socket(self, ssl_version=None, ciphers=None):
# Insecure context without remote certificate verification
# This logic is a bit messy to try and support various configurations
ssl_context = ssl.SSLContext(protocol=ssl_version or ssl.PROTOCOL_TLS_CLIENT)
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
if ciphers:
ssl_context.set_ciphers("AES256-SHA")

def _create_socket(self, ssl_version=None):
if ssl_version is not None:
self._socket = self._ssl_context.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM), ssl_version=ssl_version)
self._socket = ssl_context.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
else:
self._socket = self._ssl_context.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
self._socket = ssl_context.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
self._socket.settimeout(self.timeout)

def connect(self):
Expand Down Expand Up @@ -109,7 +111,9 @@ def _connect(self):
self._create_socket(ssl_version=ssl.PROTOCOL_SSLv3)
self._socket.connect((self.host, self.port))
else:
raise
logger.warning('Was unable to ssl handshake, trying to change cipher')
self._create_socket(ciphers="AES256-SHA")
self._socket.connect((self.host, self.port))

def disconnect(self):
"""
Expand Down

0 comments on commit 3d10cf0

Please sign in to comment.