Issue with SSL: CERTIFICATE_VERIFY_FAILED .... (_ssl.c:1129)

Hello,

Asking for help to fix this issue. Thank you in advance!

I have re-installed API client, updated .cdsapirc (url: https://cds.climate.copernicus.eu/api)

below is my request (python):
import cdsapi
import numpy as np

year = [2006] #np.arange(2004,2017)
for year in year:
for ltime in np.arange(12, 2881, 12):

    dataset = "seasonal-original-pressure-levels"
    request = {
        "originating_centre": "ecmwf",
        "system": "51",
        "variable": ["u_component_of_wind"],
        "pressure_level": [
            "10", "30", "50",
            "100", "200", "300",
            "400", "500", "700",
            "850", "925", "1000"
        ],
        "year": [str(year)],
        "month": ["11"],
        "day": ["01"],
        "leadtime_hour": [str(ltime)],
        "data_format": "netcdf"
    }

    target = f"./ecmwf/u/ecmwf_1101_u_{year}_{ltime:04}.nc"

    client = cdsapi.Client()
    client.retrieve(dataset, request, target)

then I get the error below:
/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/datapi/api_client.py:83: UserWarning: HTTPSConnectionPool(host=‘cds.climate.copernicus.eu’, port=443): Max retries exceeded with url: /api/catalogue/v1/messages (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)’)))
warnings.warn(str(exc), UserWarning)
Traceback (most recent call last):
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 703, in urlopen
httplib_response = self._make_request(
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 386, in _make_request
self._validate_conn(conn)
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 1042, in validate_conn
conn.connect()
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/urllib3/connection.py”, line 414, in connect
self.sock = ssl_wrap_socket(
File "/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/urllib3/util/ssl
.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/urllib3/util/ssl
.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/ssl.py”, line 501, in wrap_socket
return self.sslsocket_class._create(
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/ssl.py”, line 1041, in _create
self.do_handshake()
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/ssl.py”, line 1310, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/requests/adapters.py”, line 489, in send
resp = conn.urlopen(
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 787, in urlopen
retries = retries.increment(
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/urllib3/util/retry.py”, line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘cds.climate.copernicus.eu’, port=443): Max retries exceeded with url: /api/retrieve/v1/processes/seasonal-original-pressure-levels (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)’)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/gkim/cdi_test.py”, line 31, in
client.retrieve(dataset, request, target)
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/datapi/legacy_api_client.py”, line 169, in retrieve
submitted = self.client.submit_and_wait_on_results(
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/datapi/api_client.py”, line 413, in submit_and_wait_on_results
return self._retrieve_api.submit(collection_id, request).make_results()
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/datapi/processing.py”, line 727, in submit
return self.get_process(collection_id).submit(request)
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/datapi/processing.py”, line 716, in get_process
return Process.from_request(“get”, url, **self._request_kwargs)
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/datapi/processing.py”, line 172, in from_request
response = robust_request(
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/multiurl/http.py”, line 479, in wrapped
r = call(main_url, *args, **kwargs)
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/requests/sessions.py”, line 587, in request
resp = self.send(prep, **send_kwargs)
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/requests/sessions.py”, line 701, in send
r = adapter.send(request, **kwargs)
File “/home/gkim/miniconda3/envs/glab/lib/python3.9/site-packages/requests/adapters.py”, line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘cds.climate.copernicus.eu’, port=443): Max retries exceeded with url: /api/retrieve/v1/processes/seasonal-original-pressure-levels (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)’)))

1 Like

same here, using the conda environment

ok, I still had the “beta” URL in my key. I fixed it.

1 Like

did it work after you fix the beta URL?

1 Like

In my case I have issue Authentification failed operation not allowed.
if someone has this issue before and could help me I am new here.
ython API_request.py
2025-03-17 09:43:39,109 INFO [2024-09-26T00:00:00] Watch our Forum for Announcements, news and other discussed topics.
2025-03-17 09:43:39,109 WARNING [2024-06-16T00:00:00] CDS API syntax is changed and some keys or parameter names may have also changed. To avoid requests failing, please use the “Show API request code” tool on the dataset Download Form to check you are using the correct syntax for your API request.
Traceback (most recent call last):
File “/home/serge/Documents/Postdoc/ERA5/API_request.py”, line 59, in
client.retrieve(dataset, request).download()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/serge/anaconda3/lib/python3.12/site-packages/datapi/legacy_api_client.py”, line 169, in retrieve
submitted = self.client.submit_and_wait_on_results(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/serge/anaconda3/lib/python3.12/site-packages/datapi/api_client.py”, line 399, in submit_and_wait_on_results
return self._retrieve_api.submit(collection_id, request).get_results()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/serge/anaconda3/lib/python3.12/site-packages/datapi/processing.py”, line 794, in submit
return self.get_process(collection_id).submit(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/serge/anaconda3/lib/python3.12/site-packages/datapi/processing.py”, line 317, in submit
job = Job.from_request(
^^^^^^^^^^^^^^^^^
File “/home/serge/anaconda3/lib/python3.12/site-packages/datapi/processing.py”, line 177, in from_request
cads_raise_for_status(response)
File “/home/serge/anaconda3/lib/python3.12/site-packages/datapi/processing.py”, line 100, in cads_raise_for_status
raise requests.HTTPError(message, response=response)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://cds.climate.copernicus.eu/api/retrieve/v1/processes/reanalysis-era5-single-levels/execution
Authentication failed
operation not allowed