英文:
SSL Certificate Issue w/ Python Slack Bot
问题
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
英文:
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
答案1
得分: 1
slackclient
已被弃用。您应该改用新的 slack_sdk。新的 SDK 似乎不需要 SSL 证书,因此完全避免了这个问题。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论