Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL Error in fresh Conda environment #63

Open
RisingPhoelix opened this issue Aug 2, 2022 · 1 comment
Open

SSL Error in fresh Conda environment #63

RisingPhoelix opened this issue Aug 2, 2022 · 1 comment

Comments

@RisingPhoelix
Copy link

RisingPhoelix commented Aug 2, 2022

Hi,

I just created a fresh Anaconda environment, installed pip, OSMPythonTools, ipykernel and pandas. But when I try the example in readme.md

from OSMPythonTools.api import Api api = Api() way = api.query('way/5887599')

I get this error which states that the SSL certificate has expired:

The requested data could not be downloaded. Please check whether your internet connection is working.
Traceback (most recent call last):
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1037, in _send_output
self.send(msg)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 975, in send
self.connect()
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\ssl.py", line 512, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\ssl.py", line 1070, in _create
self.do_handshake()
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\ssl.py", line 1341, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\site-packages\OSMPythonTools\internal\cacheObject.py", line 95, in __query
response = urllib.request.urlopen(request)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 525, in open
response = meth(req, response)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 557, in error
result = self._call_chain(*args)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 749, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 519, in open
response = self._open(req, data)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)>
Traceback (most recent call last):
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1037, in _send_output
self.send(msg)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 975, in send
self.connect()
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\http\client.py", line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\ssl.py", line 512, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\ssl.py", line 1070, in _create
self.do_handshake()
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\ssl.py", line 1341, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\site-packages\OSMPythonTools\internal\cacheObject.py", line 95, in __query
response = urllib.request.urlopen(request)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 525, in open
response = meth(req, response)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 557, in error
result = self._call_chain(*args)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 749, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 519, in open
response = self._open(req, data)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\site-packages\OSMPythonTools\internal\cacheObject.py", line 48, in query
data = self.__query(queryString, params)
File "C:\Users\fherb\anaconda3\envs\OpenStreetMap\lib\site-packages\OSMPythonTools\internal\cacheObject.py", line 103, in __query
raise Exception(msg, err)
Exception: ('The requested data could not be downloaded. Please check whether your internet connection is working.', URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)')))

Edit:
Further System information:
Windows 11, Python 3.10.4, conda 4.11.0

@mocnik-science
Copy link
Owner

Dear @RisingPhoelix,

Sorry for answering so late, I was on vacation. As I do not use Anaconda and do not have a Windows environment available, I am not able to exactly check what is the issue. From what I guess, however, it is a not-up-to-date certifi package. Can you try to upgrade that one to the newest version? With pip, it would be:
pip3 install --upgrade certifi
I do not know the corresponding command for Anaconda.

In a similar case (#9), this has worked.

Best,
Franz-Benjamin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants