Skip to content

Commit ed66158

Browse files
committed
fix: honor SSL context for Slack workflow webhooks
- Update _initial_client in SlackWebhookClient to configure requests.Session with SSL verification - When ssl_context is provided, set session.verify to certifi CA bundle - Add warning when workflow webhooks cannot fully honor --use-system-ca-files setting - Ensures SSL context is respected for workflow webhook requests
1 parent 572e790 commit ed66158

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

elementary/clients/slack/client.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from abc import ABC, abstractmethod
44
from typing import Dict, List, Optional, Tuple, Union
55

6-
import requests
76
import certifi
7+
import requests
88
from ratelimit import limits, sleep_and_retry
99
from slack_sdk import WebClient, WebhookClient
1010
from slack_sdk.errors import SlackApiError
@@ -67,7 +67,7 @@ def create_client(
6767
webhook=config.slack_webhook,
6868
is_workflow=config.is_slack_workflow,
6969
tracking=tracking,
70-
ssl_context=ssl_context
70+
ssl_context=ssl_context,
7171
)
7272
return None
7373

@@ -262,7 +262,18 @@ def __init__(
262262

263263
def _initial_client(self, ssl_context: Optional[ssl.SSLContext]):
264264
if self.is_workflow:
265-
return requests.Session()
265+
session = requests.Session()
266+
if ssl_context is not None:
267+
# For workflow webhooks, requests.Session doesn't directly support ssl.SSLContext,
268+
# so we configure it to use certifi's CA bundle instead.
269+
# The ssl_context parameter indicates that certifi should be used (not system CA files).
270+
logger.warning(
271+
"Workflow webhooks use requests.Session which doesn't fully support SSLContext. "
272+
"Using certifi CA bundle for SSL verification instead of --use-system-ca-files setting."
273+
)
274+
session.verify = certifi.where()
275+
# If ssl_context is None, use system CA files (requests default behavior)
276+
return session
266277

267278
return WebhookClient(
268279
url=self.webhook,

0 commit comments

Comments
 (0)