大佬教程收集整理的这篇文章主要介绍了安装 OpenSSL 后 Python 3 SSL 失败,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
每当我在安装 openssl 后尝试运行我的 discord.py discord bot 我得到了这个巨大的错误,据我所知,它的要点是它找不到 discord 的证书。我用 Bash 和 C++ 进行了测试,它们连接正常,但是我无法通过 python 连接到任何服务器。我已经重新安装了 Certifi 和 CA 证书,以及安装了 PyOpenSSL 并手动添加了签名密钥。可能是什么问题,我该如何解决?
TraceBACk (most recent call last):
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 969,in _wrap_create_connection
return await self._loop.create_connection(*args,**kwargs) # type: ignore # noqa
file "/usr/lib/python3.8/asyncio/base_events.py",line 1050,in create_connection
transport,protocol = await self._create_connection_transport(
file "/usr/lib/python3.8/asyncio/base_events.py",line 1080,in _create_connection_transport
await waiter
file "/usr/lib/python3.8/asyncio/sslproto.py",line 529,in data_received
ssldata,apPDAta = self._sslpipe.Feed_ssldata(data)
file "/usr/lib/python3.8/asyncio/sslproto.py",line 189,in Feed_ssldata
self._sslobj.do_handshake()
file "/usr/lib/python3.8/ssl.py",line 944,in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_Failed] certificate verify Failed: unable to get local issuer certificate (_ssl.c:1123)
The above exception was the direct cause of the following exception:
TraceBACk (most recent call last):
file "./betterbot.py",line 285,in <module>
valkyrIEbot.run(TOKEN)
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/discord/clIEnt.py",line 718,in run
return future.result()
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/discord/clIEnt.py",line 697,in runner
await self.start(*args,**kwargs)
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/discord/clIEnt.py",line 660,in start
await self.login(*args,bot=bot)
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/discord/clIEnt.py",line 509,in login
await self.http.static_login(token.Strip(),bot=bot)
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/discord/http.py",line 293,in static_login
data = await self.request(Route('GET','/users/@me'))
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/discord/http.py",line 185,in request
async with self.__session.request(method,url,**kwargs) as r:
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/aiohttp/clIEnt.py",line 1117,in __aenter__
self._resp = await self._coro
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/aiohttp/clIEnt.py",line 520,in _request
conn = await self._connector.connect(
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 535,in connect
proto = await self._create_connection(req,traces,timeout)
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 892,in _create_connection
_,proto = await self._create_direct_connection(req,line 1051,in _create_direct_connection
raise last_exc
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 1020,in _create_direct_connection
transp,proto = await self._wrap_create_connection(
file "/home/valkyrIE_pilot/.local/lib/python3.8/site-packages/aiohttp/connector.py",line 971,in _wrap_create_connection
raise ClIEntConnectorCertificateError(req.connection_key,exC) from exc
aiohttp.clIEnt_exceptions.CLIENtConnectorCertificateError: CAnnot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1,'[SSL: CERTIFICATE_VERIFY_Failed] certificate verify Failed: unable to get local issuer certificate (_ssl.c:1123)')]```
我发现最好的解决方法是运行
pip install certifi
(确保您为 pip 使用正确版本的 Python,有时可以是 pip3)
然后当你完成后运行:
sudo update-ca-certificates
如果您想知道 certifi 是什么,它是一个预装了请求的包,所以如果您有一个新的 VPS,它没有安装。这是一个一次性软件包,因此安装完成后,您应该永远拥有必要的证书。如果您想自己检查它是什么,这里是 GitHub repository of certifi
和 PyPi project of certifi
度过美好的一天,快乐的编码^^
以上是大佬教程为你收集整理的安装 OpenSSL 后 Python 3 SSL 失败全部内容,希望文章能够帮你解决安装 OpenSSL 后 Python 3 SSL 失败所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。