at-gmbh / personio-py

a lightweight Personio API client
https://at-gmbh.github.io/personio-py
Apache License 2.0
26 stars 17 forks source link

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate #40

Open Ch33s3Burger opened 3 months ago

Ch33s3Burger commented 3 months ago

Hello I have got the following issue with the personio API when I try to connect. Code:

p = Personio(client_id=client_id, client_secret=client_secret)
p.authenticate()

When I exeecute the code with my environment I get the following error. But when I execute it with my global environment I don't get the error and i'm able to authenticate. It probably has to do with the certificate. The results I found on the internet suggest to install a certificate but I don't have any. Can you maybe help me with that?


Traceback (most recent call last):
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    self._validate_conn(conn)
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1099, in _validate_conn
    conn.connect()
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/connection.py", line 653, in connect
    sock_and_verified = _ssl_wrap_socket_and_match_hostname(
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/connection.py", line 806, in _ssl_wrap_socket_and_match_hostname
    ssl_sock = ssl_wrap_socket(
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 465, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 509, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.10/ssl.py", line 1100, in _create
    self.do_handshake()
  File "/usr/lib/python3.10/ssl.py", line 1371, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 491, in _make_request
    raise new_e
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 847, in urlopen
    retries = retries.increment(
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.personio.de', port=443): Max retries exceeded with url: /v1/auth?client_id=papi-8fd5c56c-c2f8-4942-9680-b86ac67dcc16&client_secret=papi-MzgzNmQwZmUtNDMwNy00YjlkLWJmMTctZGFkZDk0ZjZiZTJl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/Tracking/PersionioConnector.py", line 28, in <module>
    p.authenticate()
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/personio_py/client.py", line 71, in authenticate
    response = requests.request("POST", url, headers=self.headers, params=params)
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/home/user/Tracking/venv/lib/python3.10/site-packages/requests/adapters.py", line 517, in send
    raise SSLError(e, request=request)

requests.exceptions.SSLError: HTTPSConnectionPool(host='api.personio.de', port=443): Max retries exceeded with url: /v1/auth?client_id=_____________&client_secret=__________________ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)')))