Cadair / parfive

An asyncio based parallel file downloader for Python 3.8+
https://parfive.readthedocs.io/
MIT License
51 stars 24 forks source link

Disable ssl verify #157

Open bdrummon opened 4 months ago

bdrummon commented 4 months ago

Would it be possible to add a way to disable ssl verify in parfive? Aiohttp offers the option, but I don't see a way to pass that through to parfive? I'm having trouble downloading behind our firewall because I believe the firewall is not forwarding the appropriate cert chain. There may be a better way to handle that than disabling, but it would also be useful in debugging the situation.

nabobalis commented 3 months ago

Yeah, this would be really good to have, a simple way to disable SSL via a flag or keyword.

nabobalis commented 3 months ago

You can do something like:

import ssl

ssl._create_default_https_context = ssl._create_unverified_context

from parfive import SessionConfig

def create_session(*args,**keywords):
    from aiohttp import ClientSession, TCPConnector
    return ClientSession(connector=TCPConnector(ssl=False))

from parfive import Downloader
dl = Downloader(config=SessionConfig(aiohttp_session_generator=create_session))

Then the downloader should not use SSL. Can you see if this works for you @bdrummon

Cadair commented 3 months ago

I am loathed to add an explicit option for this, as there are potentially infinite options we could pass through to the http layer. I know what the full SessionConfig interface is clunky but it's there to allow for the customisation without putting the burden on a very large parfive API.