“SSL: CERTIFICATE_VERIFY_FAILED” error in my python telegram bot(我的PYTHON电报机器人中出现“SSL:CERTIFICATE_VERIFY_FAILED”错误)
本文介绍了我的PYTHON电报机器人中出现“SSL:CERTIFICATE_VERIFY_FAILED”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的Telegram机器人代码几周来一直工作得很好,今天我没有更改任何东西,突然我收到了[SSL:CERTIFICATE_VERIFY_FAILED]错误,我的机器人代码在我的PC上不再工作。我用的是Ubuntu 16.04,我用的是PYTHON电报机器人库。哪里出了问题,如何修复?
我的错误日志:
0|main_fil | File "/home/angel/.local/lib/python3.6/site-packages/telegram/ext/jobqueue.py", line 314, in start
0|main_fil | name="Bot:{}:job_queue".format(self._dispatcher.bot.id))
0|main_fil | File "/home/angel/.local/lib/python3.6/site-packages/telegram/bot.py", line 54, in decorator
0|main_fil | self.get_me()
0|main_fil | File "<decorator-gen-1>", line 2, in get_me
0|main_fil | File "/home/angel/.local/lib/python3.6/site-packages/telegram/bot.py", line 70, in decorator
0|main_fil | result = func(*args, **kwargs)
0|main_fil | File "/home/angel/.local/lib/python3.6/site-packages/telegram/bot.py", line 292, in get_me
0|main_fil | result = self._request.get(url, timeout=timeout)
0|main_fil | File "/home/angel/.local/lib/python3.6/site-packages/telegram/utils/request.py", line 277, in get
0|main_fil | result = self._request_wrapper('GET', url, **urlopen_kwargs)
0|main_fil | File "/home/angel/.local/lib/python3.6/site-packages/telegram/utils/request.py", line 231, in _request_wrapper
0|main_fil | raise NetworkError('urllib3 HTTPError {0}'.format(error))
0|main_fil | telegram.error.NetworkError: urllib3 HTTPError [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)
我还尝试了curl:
curl -X POST -H 'Content-Type: application/json' -d '{"chat_id": "******", "text": "Test", "disable_notification": true}' https://api.telegram.org/bot*****************/sendMessage
它返回此错误
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
在一些帖子中,他们说要将urllib3降级到1.24.1,我对此表示怀疑,但仍然是同样的错误。
我在本地使用相同的bot令牌运行脚本,运行正常
也是
angel@***:/$ python3 -m telegram
python-telegram-bot 12.6.1
certifi 2020.04.05.1
future 0.18.2
Python 3.6.8 (default, Oct 7 2019, 12:59:55) [GCC 8.3.0]
推荐答案
不是答案,但它可以启动您的机器人。
在此文件中:
AppDataLocalProgramsPythonPython39Libsite-packages elegram utils Equest.py
在第140-150行,您可以找到类似以下内容
kwargs = dict(
maxsize=con_pool_size,
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where(),
socket_options=sockopts,
timeout=urllib3.Timeout(connect=self._connect_timeout, read=read_timeout, total=None),
)
这样做,它就会起作用:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
kwargs = dict(
maxsize=con_pool_size,
cert_reqs='CERT_NONE',
ca_certs=certifi.where(),
socket_options=sockopts,
timeout=urllib3.Timeout(connect=self._connect_timeout, read=read_timeout, total=None),
)
有警告,但工作正常)
这篇关于我的PYTHON电报机器人中出现“SSL:CERTIFICATE_VERIFY_FAILED”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:我的PYTHON电报机器人中出现“SSL:CERTIFICATE_VERIFY_FAILED”错误


基础教程推荐
猜你喜欢
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 求两个直方图的卷积 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 包装空间模型 2022-01-01