[Trac_gajim-plugins] [Gajim Plugins] #156: SSL: CERTIFICATE_VERIFY_FAILED on http_upload
Gajim Plugins
trac at gajim.org
Sun Nov 13 17:15:57 CET 2016
#156: SSL: CERTIFICATE_VERIFY_FAILED on http_upload
-------------------------------------------------+-------------------------
Reporter: marcus@… | Owner:
Type: defect | Status: new
Priority: normal | Component:
Keywords: http_upload, | HttpUploadPlugin
CERTIFICATE_VERIFY_FAILED | Blocked By:
Blocking: |
-------------------------------------------------+-------------------------
Version: Gajim 0.16.6
OS: Linux / Windows 7
Server: ejabberd
When uploading file with http_upload I get following error:
Exception in thread Thread-61:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/share/gajim/src/gui_interface.py", line 3117, in
thread_function
output = func(*func_args)
File "/home/opolch/.local/share/gajim/plugins/httpupload/httpupload.py",
line 488, in uploader
transfer = urllib2.urlopen(request, timeout=30)
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:590)>
After changing function def_uploader(): as shown below it works. This
means to not verify the certificate anymore. Is that the recommended way
for a unsigned cert?
def uploader():
progress_messages.put(_('Uploading file via HTTP...'))
try:
#################################
# SSL_CERTIFICATE_ERROR fix
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
#################################
headers = {'User-Agent': 'Gajim %s' % gajim.version,
'Content-Type': mime_type}
request =
urllib2.Request(put.getData().encode("utf-8"), data=data, headers=headers)
request.get_method = lambda: 'PUT'
log.debug("opening urllib2 upload request...")
transfer = urllib2.urlopen(request, timeout=30,
context=context)
#transfer = urllib2.urlopen(request, timeout=30)
log.debug("urllib2 upload request done, response code:
" + str(transfer.getcode()))
return transfer.getcode()
Here is the ejabberd conf:
module: ejabberd_http
port: 5443
tls: true
certfile: "/etc/ejabberd/ejabberd.pem"
request_handlers:
"": mod_http_upload
Regards,
Oliver
--
Ticket URL: <http://trac-plugins.gajim.org/ticket/156>
Gajim Plugins <http://trac-plugins.gajim.org/>
Gajim Plugins
More information about the Trac_gajim-plugins
mailing list