python报错aiohttp.client_exceptions.ClientConnectorCertificateError,Cannot connect to host:443 解决

python 连接接口报错
报错如下:

aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to  host:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)')]

SSL handshake failed on verifying the certificate
protocol: <asyncio.sslproto.SSLProtocol object at 0x000000B1D4E2A7F0>
transport: <_SelectorSocketTransport fd=708 read=polling write=<idle, bufsize=0>>

解决方案:

# conn = aiohttp.TCPConnector(verify_ssl=False)  # 防止ssl报错
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(limit=64,verify_ssl=False)) as session:

加上verify_ssl=False后成功。

你可能感兴趣的:(python,python)