Git Product home page Git Product logo

Comments (7)

jjlee avatar jjlee commented on July 17, 2024

This is documented urllib2 behaviour, so I'm calling this a feature request.

Personally it doesn't matter to me that it doesn't check certificates. Seems few other people care much either, since nobody has fixed it in urllib2.

Would you like to implement this? Best to do it in urllib2 first.

from mechanize.

andersk avatar andersk commented on July 17, 2024

It was fixed in Python 3.2:
http://bugs.python.org/issue9003
http://docs.python.org/py3k/library/urllib.request.html#urllib.request.urlopen

I recognize that it may be some time before mechanize gets ported to Python 3. But given that mechanize forks several other parts of urllib2, maybe it would be reasonable to also include a patched or wrapped HTTPSConnection with a backported fix.

Until then, there should at least be warnings in the mechanize documentation, like there are in the urllib2 documentation.

from mechanize.

jjlee avatar jjlee commented on July 17, 2024

The mechanize documentation includes the urllib2 documentation "by reference".

Re backporting: feel free to do it. Again, I think it would be best to do this initially as a patch against Python (even if it doesn't get applied there) rather than mechanize.

from mechanize.

andersk avatar andersk commented on July 17, 2024

Iā€™m not sure I understand. Like I said, there already is a patch against Python, which I linked to in my previous comment, and it was applied in Python 3.2.

Iā€™m willing to try to write the mechanize patch; just trying to make sure we agree on how it should be done.

from mechanize.

jjlee avatar jjlee commented on July 17, 2024

So I'm saying that if you want to backport that patch to Python 2, go ahead. I have no idea what is involved in that since I know nothing about Python 3.

from mechanize.

ab avatar ab commented on July 17, 2024

You might find this gist useful if you want to implement cert verification: https://gist.github.com/1347055

from mechanize.

hurzl avatar hurzl commented on July 17, 2024

Is the new behaviour to fail always on https like urllib2 does?

In urllib2 I can define and use an ssl context with .verify_mode= ssl.CERT_NONE. Can I do this with mechanize?

  File "/usr/local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 541, in submit
    return self.open(self.click(*args, **kwds))
  File "/usr/local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 203, in open
    return self._mech_open(url, data, timeout=timeout)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 230, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_opener.py", line 204, in open
    response = meth(req, response)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 457, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_opener.py", line 221, in error
    result = apply(self._call_chain, args)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 332, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 571, in http_error_302
    return self.parent.open(new)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 203, in open
    return self._mech_open(url, data, timeout=timeout)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 230, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_opener.py", line 193, in open
    response = urlopen(self, req, data)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 344, in _open
    '_open', req)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 332, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 1170, in https_open
    return self.do_open(conn_factory, req)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 1118, in do_open
    raise URLError(err)
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>

from mechanize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.