List cloudflare zone and face error SSL: CERTIFICATE_VERIFY_FAILED

I am trying to run the following code to list all zone in my cloudflare account.

def main():
cf = CloudFlare.CloudFlare(email=‘email’, token=‘00000000000000000000000000000000’)
zones = cf.zones.get()
for zone in zones:
zone_id = zone[‘id’]
zone_name = zone[‘name’]
print(zone_id, zone_name)

if name == ‘main’:
main()

But faced the following error, do you have any idea?

Traceback (most recent call last):
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connectionpool.py”, line 699, in urlopen
httplib_response = self._make_request(
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connectionpool.py”, line 382, in _make_request
self._validate_conn(conn)
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connectionpool.py”, line 1010, in validate_conn
conn.connect()
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connection.py”, line 411, in connect
self.sock = ssl_wrap_socket(
File "C:\Program Files\Python3.9\lib\site-packages\urllib3\util\ssl
.py", line 428, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "C:\Program Files\Python3.9\lib\site-packages\urllib3\util\ssl
.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File “C:\Program Files\Python3.9\lib\ssl.py”, line 500, in wrap_socket
return self.sslsocket_class._create(
File “C:\Program Files\Python3.9\lib\ssl.py”, line 1040, in _create
self.do_handshake()
File “C:\Program Files\Python3.9\lib\ssl.py”, line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\adapters.py”, line 439, in send
resp = conn.urlopen(
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connectionpool.py”, line 755, in urlopen
retries = retries.increment(
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\util\retry.py”, line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘api.cloudflare.com’, port=443): Max retries exceeded with url: /client/v4/zones (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 203, in _call_network
response = self.network(method, url, headers, params, data, files)
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\network.py”, line 29, in call
return self.session.get(url,
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py”, line 555, in get
return self.request(‘GET’, url, **kwargs)
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py”, line 542, in request
resp = self.send(prep, **send_kwargs)
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py”, line 655, in send
r = adapter.send(request, **kwargs)
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\adapters.py”, line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘api.cloudflare.com’, port=443): Max retries exceeded with url: /client/v4/zones (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:/Rock_Wang/python code/listzone.py”, line 12, in
main()
File “C:/Rock_Wang/python code/listzone.py”, line 5, in main
zones = cf.zones.get()
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 672, in get
return self._base.call_with_auth(‘GET’, self._parts,
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 126, in call_with_auth
return self._call(method, headers, parts,
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 427, in _call
response_data = self._raw(method, headers, parts,
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 275, in _raw
[response_type, response_code, response_data] = self._call_network(method,
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 207, in _call_network
raise CloudFlareAPIError(0, ‘connection failed.’)
CloudFlare.exceptions.CloudFlareAPIError: connection failed.

================= RESTART: C:/Rock_Wang/python code/listzone.py ================
Traceback (most recent call last):
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connectionpool.py”, line 699, in urlopen
httplib_response = self._make_request(
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connectionpool.py”, line 382, in _make_request
self._validate_conn(conn)
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connectionpool.py”, line 1010, in validate_conn
conn.connect()
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connection.py”, line 411, in connect
self.sock = ssl_wrap_socket(
File "C:\Program Files\Python3.9\lib\site-packages\urllib3\util\ssl
.py", line 428, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "C:\Program Files\Python3.9\lib\site-packages\urllib3\util\ssl
.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File “C:\Program Files\Python3.9\lib\ssl.py”, line 500, in wrap_socket
return self.sslsocket_class._create(
File “C:\Program Files\Python3.9\lib\ssl.py”, line 1040, in _create
self.do_handshake()
File “C:\Program Files\Python3.9\lib\ssl.py”, line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\adapters.py”, line 439, in send
resp = conn.urlopen(
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\connectionpool.py”, line 755, in urlopen
retries = retries.increment(
File “C:\Program Files\Python3.9\lib\site-packages\urllib3\util\retry.py”, line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘api.cloudflare.com’, port=443): Max retries exceeded with url: /client/v4/zones (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 203, in _call_network
response = self.network(method, url, headers, params, data, files)
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\network.py”, line 29, in call
return self.session.get(url,
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py”, line 555, in get
return self.request(‘GET’, url, **kwargs)
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py”, line 542, in request
resp = self.send(prep, **send_kwargs)
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py”, line 655, in send
r = adapter.send(request, **kwargs)
File “C:\Users\rock.wang\AppData\Roaming\Python\Python39\site-packages\requests\adapters.py”, line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘api.cloudflare.com’, port=443): Max retries exceeded with url: /client/v4/zones (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:/Rock_Wang/python code/listzone.py”, line 12, in
main()
File “C:/Rock_Wang/python code/listzone.py”, line 5, in main
zones = cf.zones.get()
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 672, in get
return self._base.call_with_auth(‘GET’, self._parts,
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 126, in call_with_auth
return self._call(method, headers, parts,
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 427, in _call
response_data = self._raw(method, headers, parts,
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 275, in _raw
[response_type, response_code, response_data] = self._call_network(method,
File “C:\Program Files\Python3.9\lib\site-packages\CloudFlare\cloudflare.py”, line 207, in _call_network
raise CloudFlareAPIError(0, ‘connection failed.’)
CloudFlare.exceptions.CloudFlareAPIError: connection failed.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.