解决pyhtonaiohttpssl:证书报错问题,
错误信息>
Cannotconnecttohostoapi.dingtalk.com:443ssl:None[[SSL:CERTIFICATE_VERIFY_FAILED]certificateverifyfailed(_ssl.c:777)]
解决方案就是取消ssl验证;
aiohttp.Connector使用自定义创建ssl_context(有关如何创建ssl上下文对象,请参阅https://docs.python.org/3/library/ssl.html)。
也许您必须使用您的证书链正确配置上下文。
PSaiohttp.Connector(verify_ssl)禁用SSL证书验证。
在ClientSession()传入ssl配置
importasyncio
importsys
importpymysql.cursors
fromaiohttpimportClientSession
fromaiohttpimportTCPConnector
asyncdefpostmsg(url,msg):
asyncwithClientSession(connector=TCPConnector(verify_ssl=False))assession:
#data={"msgtype":"text","text":{"content":msg},"at":{"atMobiles":["17633919216"],"isAtAll":"false"}}
asyncwithsession.post(url,data=json.dumps(msg),headers=headers)asresponse:
response=awaitresponse.read()
#print(response)
returnresponse
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h54671.shtml