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)