Comments (7)
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.
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.
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.
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.
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.
You might find this gist useful if you want to implement cert verification: https://gist.github.com/1347055
from mechanize.
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)
- _form.py have an error
- HTML5 element not visible
- Updating referer in case of URL redirection
- ImportError HOT 2
- ParseError: OPTION outside of SELECT if there is <option> tag somewhere inside <script> tag
- urllib2.URLError: <urlopen error no host given> HOT 1
- Does this mechanize poke private implementation of socket.py?
- open response in browser after submit forms
- Mechanize parses <script> contents with bad results HOT 1
- Incorrect textarea CRLF normalization when parsing chunks.
- add_file with image/gif file
- Python Mechanize can no longer log into Amazon.com
- mechanize giving ssl errors
- Plan ongoing support for this library or mark it deprecated here & on PyPI HOT 11
- Authorization with NTLM getting AttributeError: HTTPResponse instance has no attribute '__iter__' HOT 2
- socket.error: [Errno 54] Connection reset by peer on very specific case
- browser.submit() randomly stucks forever without throwing an exception
- clean uninstallation
- Support Python 3 HOT 4
- Fake socket is not compatible with PyPy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mechanize.