CS-SI / eodag

Earth Observation Data Access Gateway
https://eodag.readthedocs.io
Apache License 2.0
316 stars 44 forks source link

intercept SSL error during product types discovery authentication #1320

Open sbrunato opened 2 weeks ago

sbrunato commented 2 weeks ago

When running server-mode, we have a SSL error when discovering dedl product types that stops the server (and should not):

Traceback (most recent call last):
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.10/site-packages/starlette/routing.py", line 732, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/lib/python3.10/contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "/home/sylvain/workspace/eodag/eodag/rest/server.py", line 131, in lifespan
    eodag_api_init()
  File "/home/sylvain/workspace/eodag/eodag/rest/core.py", line 679, in eodag_api_init
    eodag_api.fetch_product_types_list()
  File "/home/sylvain/workspace/eodag/eodag/api/core.py", line 740, in fetch_product_types_list
    self.discover_product_types(provider=provider) or {}
  File "/home/sylvain/workspace/eodag/eodag/api/core.py", line 808, in discover_product_types
    kwargs["auth"] = auth_plugin.authenticate()
  File "/home/sylvain/workspace/eodag/eodag/plugins/authentication/token_exchange.py", line 93, in authenticate
    subject_auth = self.subject.authenticate()
  File "/home/sylvain/workspace/eodag/eodag/plugins/authentication/openid_connect.py", line 290, in authenticate
    self.token_info["access_token"] = self._get_access_token()
  File "/home/sylvain/workspace/eodag/eodag/plugins/authentication/openid_connect.py", line 91, in _get_access_token
    res = self._request_new_token()
  File "/home/sylvain/workspace/eodag/eodag/plugins/authentication/openid_connect.py", line 302, in _request_new_token
    authentication_response = self.authenticate_user(state)
  File "/home/sylvain/workspace/eodag/eodag/plugins/authentication/openid_connect.py", line 407, in authenticate_user
    return self.session.post(
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.10/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.10/site-packages/requests/sessions.py", line 724, in send
    history = [resp for resp in gen]
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.10/site-packages/requests/sessions.py", line 724, in <listcomp>
    history = [resp for resp in gen]
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.10/site-packages/requests/sessions.py", line 265, in resolve_redirects
    resp = self.send(
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.10/site-packages/requests/adapters.py", line 698, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='hda.data.destination-earth.eu', port=443): Max retries exceeded with url: /stac?state=AEaUlq4ascdEeKRoByXBlu&session_state=c9e103d9-82e8-4ae8-a4f9-6e7605e67e5d&iss=https%3A%2F%2Fauth.destine.eu%2Frealms%2Fdesp&code=036881c1-082e-4131-ba6f-c78318c04d7a.c9e103d9-82e8-4ae8-a4f9-6e7605e67e5d.071a29cc-efe7-42a3-9803-04846d6f6bde (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1007)')))