欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-04-05 16:14:04
解决pyhton aiohttp ssl:证书报错问题, 错误信息> Cannot connect to host oapi.dingtalk.com:443 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed ( ......

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

错误信息>

cannot connect to host oapi.dingtalk.com:443 ssl:none [[ssl: certificate_verify_failed] certificate verify failed (_ssl.c:777)]

 

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

aiohttp.connector使用自定义创建ssl_context(有关如何创建ssl上下文对象,请参阅)。
也许您必须使用您的证书链正确配置上下文。

ps aiohttp.connector(verify_ssl)禁用ssl证书验证。

在 clientsession()传入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