From 0724b5d170b45005ba16ef5d88b1257ba291fb7c Mon Sep 17 00:00:00 2001 From: Chris Swan <478926+cpswan@users.noreply.github.com> Date: Wed, 5 Aug 2026 11:23:23 +0100 Subject: [PATCH 1/3] fix: Avoid use of TLS < v1.2 --- at_client/connections/atconnection.py | 7 +++++-- at_client/connections/atmonitorconnection.py | 2 +- at_client/connections/atrootconnection.py | 4 ++-- at_client/connections/atsecondaryconnection.py | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/at_client/connections/atconnection.py b/at_client/connections/atconnection.py index 15b41d1..8628a72 100644 --- a/at_client/connections/atconnection.py +++ b/at_client/connections/atconnection.py @@ -15,16 +15,19 @@ class AtConnection(ABC): Abstract base class for connecting to and communicating with an atprotocol server. """ - def __init__(self, host:str, port:int, context:ssl.SSLContext, verbose:bool=False): + def __init__(self, host:str, port:int, context:ssl.SSLContext=None, verbose:bool=False): """ Initialize the AtConnection object. Parameters: - host (str): The host name or IP address of the server. - port (int): The port number of the server. - - context (ssl.SSLContext): The SSL context for secure connections. + - context (ssl.SSLContext, optional): The SSL context for secure connections. - verbose (bool, optional): Indicates if verbose output is enabled (default is False). """ + if context is None: + context = ssl.create_default_context() + context.minimum_version = ssl.TLSVersion.TLS1_2 self._host = host self._port = port self._context = context diff --git a/at_client/connections/atmonitorconnection.py b/at_client/connections/atmonitorconnection.py index cb909cb..0fd18b0 100644 --- a/at_client/connections/atmonitorconnection.py +++ b/at_client/connections/atmonitorconnection.py @@ -18,7 +18,7 @@ class AtMonitorConnection(AtSecondaryConnection): should_be_running: bool = False def __init__(self, queue: queue.Queue, atsign: AtSign, address: Address, - context: ssl.SSLContext = ssl.create_default_context(), + context: ssl.SSLContext = None, verbose: bool = True, regex=".*", last_received_time: int = 0): self.atsign = atsign self.queue = queue diff --git a/at_client/connections/atrootconnection.py b/at_client/connections/atrootconnection.py index 71540e1..2e78930 100644 --- a/at_client/connections/atrootconnection.py +++ b/at_client/connections/atrootconnection.py @@ -14,7 +14,7 @@ class AtRootConnection(AtConnection): __instance = None @staticmethod - def get_instance(host:str='root.atsign.org', port:int=64, context:ssl.SSLContext=ssl.create_default_context(), verbose:bool=False): + def get_instance(host:str='root.atsign.org', port:int=64, context:ssl.SSLContext=None, verbose:bool=False): """ Get an instance of AtRootConnection using the singleton pattern. @@ -25,7 +25,7 @@ def get_instance(host:str='root.atsign.org', port:int=64, context:ssl.SSLContext port : int, optional The port number of the root server (default is 64). context : ssl.SSLContext, optional - The SSL context for secure connections (default is ssl.create_default_context()). + The SSL context for secure connections (default is None). verbose : bool, optional Indicates if verbose output is enabled (default is False). diff --git a/at_client/connections/atsecondaryconnection.py b/at_client/connections/atsecondaryconnection.py index f7a8e42..9a56296 100644 --- a/at_client/connections/atsecondaryconnection.py +++ b/at_client/connections/atsecondaryconnection.py @@ -9,7 +9,7 @@ class AtSecondaryConnection(AtConnection): Subclass of AtConnection representing a connection to the secondary server in the atprotocol. """ - def __init__(self, address: Address, context:ssl.SSLContext=ssl.create_default_context(), verbose:bool=False): + def __init__(self, address: Address, context:ssl.SSLContext=None, verbose:bool=False): """ Initialize the AtSecondaryConnection object. @@ -20,7 +20,7 @@ def __init__(self, address: Address, context:ssl.SSLContext=ssl.create_default_c port : int The port number of the secondary server. context : ssl.SSLContext, optional - The SSL context for secure connections (default is ssl.create_default_context()). + The SSL context for secure connections (default is None). verbose : bool, optional Indicates if verbose output is enabled (default is False). """ From 442c68afbf27fb1a0246151583a0c43e108bc689 Mon Sep 17 00:00:00 2001 From: Chris Swan <478926+cpswan@users.noreply.github.com> Date: Wed, 5 Aug 2026 11:39:27 +0100 Subject: [PATCH 2/3] fix: TLSv1_2 --- at_client/connections/atconnection.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/at_client/connections/atconnection.py b/at_client/connections/atconnection.py index 8628a72..7c06da6 100644 --- a/at_client/connections/atconnection.py +++ b/at_client/connections/atconnection.py @@ -25,12 +25,19 @@ def __init__(self, host:str, port:int, context:ssl.SSLContext=None, verbose:bool - context (ssl.SSLContext, optional): The SSL context for secure connections. - verbose (bool, optional): Indicates if verbose output is enabled (default is False). """ - if context is None: - context = ssl.create_default_context() - context.minimum_version = ssl.TLSVersion.TLS1_2 + if isinstance(context, ssl.SSLContext): + context.minimum_version = ssl.TLSVersion.TLSv1_2 + self._context = context + elif isinstance(context, bool): + verbose = context + self._context = ssl.create_default_context() + self._context.minimum_version = ssl.TLSVersion.TLSv1_2 + else: + self._context = ssl.create_default_context() + self._context.minimum_version = ssl.TLSVersion.TLSv1_2 + self._host = host self._port = port - self._context = context self._addr_info = socket.getaddrinfo(host, port)[0][-1] self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._secure_root_socket = None From bebb0dc76fc690df9ad4ba0dc1b72d28b3cf258c Mon Sep 17 00:00:00 2001 From: Chris Swan <478926+cpswan@users.noreply.github.com> Date: Wed, 5 Aug 2026 13:16:17 +0100 Subject: [PATCH 3/3] chore: Bump version number --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3c8b23e..d624f3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "atsdk" -version = "0.2.73" +version = "0.2.74" description = "Python SDK for atPlatform" authors = ["Umang Shah ","Chris Swan "] maintainers = ["Chris Swan "]