无法连接到主机 discordapp.com:443 ssl:default [[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:852)]

Posted

技术标签:

【中文标题】无法连接到主机 discordapp.com:443 ssl:default [[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:852)]【英文标题】:Cannot connect to host discordapp.com:443 ssl:default [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)] 【发布时间】:2020-09-07 15:11:36 【问题描述】:

我正在尝试解决我目前遇到的这个问题。我真的不明白错误本身,我一直在研究多种表格并试图解决这个问题,但无济于事。

任何反馈和帮助将不胜感激。谢谢!

平台:Windows 10

Python:Python3.6.8

意图:试图运行不和谐的机器人应用程序。

结果:我收到此认证错误,导致程序无法连接到 discord。

注意:由于某种原因,该机器人可以在我的另一台 Windows 10 计算机上正常运行。

错误日志

Traceback (most recent call last):
  File "C:\Users\oiabe\Desktop\AyStar\Oracle(V6).py", line 360, in <module>
    client.run("TOKEN")
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 640, in run
    return future.result()
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 621, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 584, in start
    await self.login(*args, bot=bot)
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 442, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\http.py", line 261, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\http.py", line 165, in request
    async with self.__session.request(method, url, **kwargs) as r:
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\client.py", line 483, in _request
    timeout=real_timeout
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\connector.py", line 859, in _create_connection
    req, traces, timeout)
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\connector.py", line 986, in _create_direct_connection
    req=req, client_error=client_error)
  File "C:\Users\oiabe\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\connector.py", line 941, in _wrap_create_connection
    raise ClientConnectorSSLError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host discordapp.com:443 ssl:default [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)]

【问题讨论】:

【参考方案1】:

一种解决方案是取消 ssl 验证

import asyncio
import sys
import pymysql.cursors
from aiohttp import ClientSession
from aiohttp import TCPConnector





async def postmsg(url,msg):
    async with ClientSession(connector=TCPConnector(verify_ssl=False)) as session:
        # data="msgtype":"text","text":"content":msg,"at":"atMobiles":["17633919216"],"isAtAll":"false"
        async with session.post(url,data=json.dumps(msg),headers=headers) as response:
            response = await response.read()
            # print(response)
            return  response

【讨论】:

以上是关于无法连接到主机 discordapp.com:443 ssl:default [[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:852)]的主要内容,如果未能解决你的问题,请参考以下文章

MySQL Workbench 连接到 AWS,收到错误“无法连接到本地主机”

无法连接到 ejabberd 本地主机

无法连接到 ejabberd 服务器:未知主机异常

无法连接到总线:主机在 ubuntu 中已关闭

EasyPHP 无法连接到本地主机(端口 8080)

jmx 无法连接到本地主机