finos/symphony-bdk-python

Python 3.10 ClientConnectorSSLError

NirbheySymTSE opened this issue · 1 comments

Bug Report

Python BDK (tested on v2.2.0 & 2.3.0) both run into TLS issues when run from Python 3.10:
ClientConnectorSSLError: Cannot connect to host sup.symphony.com:443 ssl:default [Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801)]

The bot functions fine on Python versions 3.9 and 3.8. As Python 3.10 is required for my project, could a workaround or fix be provided?

Steps to Reproduce:

  1. Install Python 3.10 and using that python version, attempt to run your Python BDK

Expected Result:

Expected result would be that the bot would succesfully connect to the Datafeed and start capturing messages being sent to the bot, as shown below for Python 3.9:
2022-06-17 11:27:49,522 - symphony.bdk.core.activity.registry - DEBUG - Registering slash command with command=/hello, mention_bot=True 2022-06-17 11:27:49,523 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <symphony.bdk.core.activity.command.SlashCommandActivity object at 0x104160e80> 2022-06-17 11:27:49,523 - symphony.bdk.core.activity.registry - DEBUG - Registering slash command with command=/connect, mention_bot=True 2022-06-17 11:27:49,523 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <symphony.bdk.core.activity.command.SlashCommandActivity object at 0x104160e20> 2022-06-17 11:27:49,523 - symphony.bdk.core.service.datafeed.abstract_datafeed_loop - DEBUG - Starting datafeed loop 2022-06-17 11:30:47,424 - root - DEBUG - Message received from Nirbhey Jain: <div data-format="PresentationML" data-version="2.0" class="wysiwyg"><p>/notifications</p></div>

Actual Result:

Instead, these TLS issues occur:
Collection(Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'jira_bot'), 'jira_bot') 2022-06-17 11:35:30,233 - root - INFO - Running bot application... 2022-06-17 11:35:30,237 - asyncio - DEBUG - Using selector: KqueueSelector 2022-06-17 11:35:30,488 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <activities.EchoCommandActivity object at 0x10e53dc60> 2022-06-17 11:35:30,488 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <activities.GreetUserJoinedActivity object at 0x10e53dcc0> 2022-06-17 11:35:30,493 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <gif_activities.GifSlashCommand object at 0x10e53dd20> 2022-06-17 11:35:30,494 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <gif_activities.GifFormReplyActivity object at 0x10e53dd50> 2022-06-17 11:35:30,498 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <login_activities.LoginSlashCommand object at 0x10e53e350> 2022-06-17 11:35:30,499 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <login_activities.LoginActivity object at 0x10e53e260> 2022-06-17 11:35:30,503 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <mytickets.MySlashCommand object at 0x10e53ea10> 2022-06-17 11:35:30,506 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <mytickets.TeamSlashCommand object at 0x10e56bfa0> 2022-06-17 11:35:30,509 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <mytickets.WatchedSlashCommand object at 0x10e53fbe0> 2022-06-17 11:35:30,511 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <mytickets.BlockerSlashCommand object at 0x10e568430> 2022-06-17 11:35:30,513 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <notifications_activities.UpdateNotificationsSlashCommand object at 0x10e53ea70> 2022-06-17 11:35:30,514 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <notifications_activities.UpdateNotificationsFormReplyActivity object at 0x10e56bee0> 2022-06-17 11:35:30,514 - symphony.bdk.core.activity.registry - DEBUG - Registering slash command with command=/hello, mention_bot=True 2022-06-17 11:35:30,514 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <symphony.bdk.core.activity.command.SlashCommandActivity object at 0x10e568790> 2022-06-17 11:35:30,514 - symphony.bdk.core.activity.registry - DEBUG - Registering slash command with command=/connect, mention_bot=True 2022-06-17 11:35:30,516 - symphony.bdk.core.activity.registry - DEBUG - Registering new activity <symphony.bdk.core.activity.command.SlashCommandActivity object at 0x10e568670> 2022-06-17 11:35:30,516 - symphony.bdk.core.service.datafeed.abstract_datafeed_loop - DEBUG - Starting datafeed loop 2022-06-17 11:35:31,020 - symphony.bdk.core.auth.bot_authenticator - INFO - Retrying symphony.bdk.core.auth.bot_authenticator.BotAuthenticatorRsa._authenticate_and_get_token in 2.0 seconds as it raised ClientConnectorSSLError: Cannot connect to host sup.symphony.com:443 ssl:default [Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801)]. 2022-06-17 11:35:33,372 - symphony.bdk.core.auth.bot_authenticator - INFO - Retrying symphony.bdk.core.auth.bot_authenticator.BotAuthenticatorRsa._authenticate_and_get_token in 4.0 seconds as it raised ClientConnectorSSLError: Cannot connect to host sup.symphony.com:443 ssl:default [Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801)]. 2022-06-17 11:35:37,754 - symphony.bdk.core.auth.bot_authenticator - INFO - Retrying symphony.bdk.core.auth.bot_authenticator.BotAuthenticatorRsa._authenticate_and_get_token in 8.0 seconds as it raised ClientConnectorSSLError: Cannot connect to host sup.symphony.com:443 ssl:default [Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801)]. 2022-06-17 11:35:38,751 - root - INFO - Ending bot application

Going through the trace, all errors occur within libraries that come with the BDK

Environment:

Python BDK version 2.3.0 on MacOS Catalina 10.15.7, running from a virtual PyEnv installation of 3.10.4. The project also has the following dependencies:
requirements.txt

ystxn commented

Looks like this is the cause: mjs/imapclient#466

Only one instance of SSL context being creaed in Python BDK code:

ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH, cafile=configuration.ssl_ca_cert)

Fix:

ssl_context = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH, cafile=configuration.ssl_ca_cert)