theelous3 / asks

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

No option to ignore SSL/TLS certificate verification like request's verify=False #74

Closed ric2b closed 6 years ago

ric2b commented 6 years ago

For local development it's useful to be able to ignore invalid certificates. Requests allows this via a keyword argument to a request (verify=False). It's not ideal, it still prints warnings to the console which can only be disabled in a very ugly way, at least from what I recall.

I tried to do the same with an asks request, since the API is so similar, but no luck, I can't get a request to be made if the certificate fails verification.

I think it's a useful feature that doesn't seem hard to implement, if you agree but prefer to work on other features I can take a crack at it during the weekend and send you a pull request.

theelous3 commented 6 years ago

By all means take a crack at it! Take a crack at everything :D

I'll look in to it myself too. Check the repo for a branch for this if you haven't started before the weekend in case I've begun :)

jmaroeder commented 6 years ago

Strange timing! I just ran into this need for myself. It looks like first of all, multio needs to support passing a context in open_connection. I'm going to work on that right now

smurfix commented 6 years ago

While you're at it: a missing certificate results in an UnboundLocalError.

  File "/usr/lib/python3/dist-packages/asks/sessions.py", line 222, in request
    return r
UnboundLocalError: local variable 'r' referenced before assignment
theelous3 commented 6 years ago

Ah, good. Am intentionally not catching broad exceptions in a particular place to root out odd ones like this. Hope you don't mind being a bit of a guinea pig there :P

I'll patch this case tonight.

jmehnle commented 6 years ago

I have a need for this as well. Let me know if there's anything I can help with. If you have work in progress, a preliminary PR could be useful.

PortWhisperer commented 5 years ago

Can anyone explain how to use this parameter to mimic ssl_verify=False? With trio+asks I'm getting SSLEOFERRORs when trying to connect to an HTTPS server that's using a self-signed certificate. I'm not able to find any information on how to get around this error, but it seems related to the SSL verification step. When i try to connect to the same domain with requests using ssl_verify=false there's no issue.

Someone suggested context = ssl.SSLContext(); context.verify_mode = ssl.CERT_NONE s.ssl_context=context

Then submitting the request. This failed to work.

EDIT: I created the following stackoverflow post which lays out the issue. It may not be related to the verification phase. But i'm not sure what's causing it. https://stackoverflow.com/questions/57742649/asks-async-https-client-ssleoferror-on-connect-attempt-to-server-with-self-s

omarryhan commented 3 years ago

I'm using the Session.request method and can't find a way to disable SSL for a single call. It's not mentioned in the docs unfortunately. What's the correct way to do it? Thanks