0

I am attempting to write a simple Slack both in Python, but am unable to connect because of an SSL issue. This has rendered all examples from tutorials I've found nonfunctional. I have also attempted several iterations on the solution using certifi as suggested in this post with no luck.

Here is the relevant code:

import slack
import os
from pathlib import Path
from dotenv import load_dotenv

import ssl
import certifi
ssl_context = ssl.create_default_context(cafile=certifi.where())

env_path = Path('.') / '.env'
load_dotenv(dotenv_path = env_path)

client = slack.WebClient(token = os.environ['SLACK_TOKEN'], ssl = ssl_context)
client.chat_postMessage(channel = '#bot-channel', text = 'Hello World!')

And the error message:

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)>

Python version is 3.10.5

Lukas Vlahos
  • 41
  • 1
  • 5

1 Answers1

1

slackclient is deprecated. You should use the new slack_sdk instead. The new sdk does not seem to require an SSL cert, so this issue is avoided entirely.

amycodes
  • 902
  • 14