theelous3 / asks

Async requests-like httplib for python.
MIT License
508 stars 63 forks source link

ssl.CertificateError: hostname doesn't match #141

Open freis opened 5 years ago

freis commented 5 years ago

Hi all, I'm using asks==2.3.6 and getting "ssl.CertificateError: hostname doesn't match". I've used the session.get(url, verify=False), still no luck, am I missing something or is this a bug? To note that I'm using ip:port to make the get.

freis commented 5 years ago

Anyone could shed some light on this issue?

carlbordum commented 5 years ago

hi @freis. It seems to me like the verify keyword was never implemented. I can implement it in the following week, if you do not want to.

To avoid issues like this in the future, it would probably be nice to have some sanity checking on the **kwargs, so users do not pass in invalid keys.

freis commented 5 years ago

Oh I was under the impression that this was implemented to bypass this issues that I'm getting.

freis commented 5 years ago

So I found the way to do this:

import asks
import trio
import ssl

ssl_ctx = ssl.create_default_context()
ssl_ctx.check_hostname = False
ssl_ctx.verify_mode = ssl.CERT_NONE

async def example():
    s = asks.Session(ssl_context=ssl_ctx)
    r = await s.get(url)
    print(r.url)

trio.run(example)

However it would be nice to have the ability to do something like request with the keyword verify=False to skip this setup I would say.