urllib2 error with version 0.2.1
allanino opened this issue · 3 comments
After the removal of requests package dependency in version 0.2.1, I started to get SSL certificate errors triggered by urrllib2. See the traceback:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/slack_log_handler/__init__.py", line 48, in emit
urlopen(req, json.dumps(content))
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1240, in https_open
context=self._context)
File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>
I managed to avoid this error adding the following snippet to my code, but that just doesn't feel right:
import ssl
if hasattr(ssl, '_create_unverified_context'):
ssl._create_default_https_context = ssl._create_unverified_context
Hi,
There was a bug with Python 3.x, which I just fixed in 0.2.2, but I could not reproduce the SSL certificate error on my machine.
I tried both on Ubuntu 14.04 and on ArchLinux.
Could you tell me what OS you are using?
Hi!
I'm using Alpine Linux, but I solved this issue.
After your question I realized what was the problem, so I fixed it by installing the ca-certificates
package.
Sorry for the trouble and thanks for the help.
Glad to hear it worked for you too!
No problem!
Thanks for sharing your issue, I added it to the README 👍