最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Please tell me how to disable SSL for aiohttpSession? - Stack Overflow

programmeradmin3浏览0评论

I'm writing a small python 3.12 bot using aiogram3 and asyncio.

The bot will be running at work, on one of the servers. There is a security policy that allows access to the external Internet only through a corporate proxy, so I also had to use aiohttp.

I ran into a problem, I get an SSL validation error, because the http proxy is working, possibly for another reason. So, I'm asking for help - I've tried literally 10-15 Google search pages, neural networks, and the documentation of the libraries used, but I still haven't found a way to disable ssl verification.

Code:

import aiohttp
import asyncio
import logging
from aiogram import Bot, Dispatcher, types
from aiogram.filtersmand import Command
from aiohttp import BasicAuth
from aiogram.client.session.aiohttp import AiohttpSession

auth = BasicAuth(login='Login', password='Pass')
session = AiohttpSession(proxy=(':8080', auth))

logging.basicConfig(level=logging.INFO)
bot = Bot(token="token", session=session)
dp = Dispatcher()

@dp.message(Command("start"))
async def cmd_start(message: types.Message):
    await message.answer("Hello!")

async def main():
    await dp.start_polling(bot)

if __name__ == "__main__":
    asyncio.run(main())

Error: .jpg

What I've already tried:

1). Use the TCPConnector(ssl = False)

2). Run the script through a bat-file, enabling/disabling the proxy in it

3). Create ssl_context, disable it, etc. (maybe it work, but i can't use context in session)

发布评论

评论列表(0)

  1. 暂无评论