解决pyhton aiohttp ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)

解决pyhton aiohttp ssl:证书报错问题,html

错误信息>python

Cannot connect to host oapi.dingtalk.com:443 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)]mysql

 

解决方案就是取消ssl验证;sql

aiohttp.Connector使用自定义建立ssl_context有关如何建立ssl上下文对象,请参阅https://docs.python.org/3/library/ssl.html)。
也许您必须使用您的证书链正确配置上下文。json

PS aiohttp.Connector(verify_ssl)禁用SSL证书验证。api

在 ClientSession()传入ssl 配置session

 1 import asyncio  2 import sys  3 import pymysql.cursors  4 from aiohttp import ClientSession  5 from aiohttp import TCPConnector  6 
 7 
 8 
 9 
10 
11 async def postmsg(url,msg): 12     async with ClientSession(connector=TCPConnector(verify_ssl=False)) as session: 13         # data={"msgtype":"text","text":{"content":msg},"at":{"atMobiles":["17633919216"],"isAtAll":"false"}} 
14         async with session.post(url,data=json.dumps(msg),headers=headers) as response: 15             response = await response.read() 16             # print(response) 
17             return  response
相关文章
相关标签/搜索