ConnectionError when trying to access web service using zeep in custom app

My custom app uses zeep to collect data from a web service. however I keep getting a Connectionerror which I’m failing to solve.

[frappe@service frappe-bench]$ bench --site admin.myapp execute app.module.function
From cffi callback <function _verify_callback at 0x2f418c0>:
Traceback (most recent call last):
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/OpenSSL/SSL.py”, line 313, in wrapper
_lib.X509_up_ref(x509)
AttributeError: ‘module’ object has no attribute ‘X509_up_ref’
Traceback (most recent call last):
File “/usr/lib64/python2.7/runpy.py”, line 162, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib64/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py”, line 117, in execute
ret = frappe.get_attr(method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/zbpayments/zbpayments/payments.py”, line 13, in zbbank
client = zeep.Client(wsdl=wsdl)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/zeep/client.py”, line 62, in init
wsdl, self.transport, settings=self.settings)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/zeep/wsdl/wsdl.py”, line 82, in init
document = self._get_xml_document(location)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/zeep/wsdl/wsdl.py”, line 143, in _get_xml_document
location, self.transport, self.location, settings=self.settings)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/zeep/loader.py”, line 75, in load_external
content = transport.load(url)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/zeep/transports.py”, line 110, in load
content = self._load_remote_data(url)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/zeep/transports.py”, line 125, in _load_remote_data
response = self.session.get(url, timeout=self.load_timeout)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/requests/sessions.py”, line 515, in get
return self.request(‘GET’, url, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/requests/sessions.py”, line 502, in request
resp = self.send(prep, **send_kwargs)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/requests/sessions.py”, line 634, in send
history = [resp for resp in gen] if allow_redirects else []
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/requests/sessions.py”, line 212, in resolve_redirects
**adapter_kwargs
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/requests/sessions.py”, line 612, in send
r = adapter.send(request, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/requests/adapters.py”, line 504, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘myapp.com’, port=443): Max retries exceeded with url: /route/toMy/App.wsdl (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)],)”,),))
[frappe@service frappe-bench]$

Maybe this link could be helpful.

Thank you @Pawan. link does enlighten a bit but I’m still without solution. I’m looking into the ‘requests’ library and getting to understand sessions and ssl. I think thats where my problem is