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 Certificates Issue - 'CERTIFICATE_VERIFY_FAILED' #49

Open
mcat-ee opened this issue Feb 12, 2022 · 1 comment
Open

SSL Certificates Issue - 'CERTIFICATE_VERIFY_FAILED' #49

mcat-ee opened this issue Feb 12, 2022 · 1 comment

Comments

@mcat-ee
Copy link

mcat-ee commented Feb 12, 2022

I'm using Python 3.9 on OSX 10.15.7 and I've been running into the following error:

  File "watch_server_and_reset.py", line 16, in hetzner_list
    list(robot.servers)
  File "/usr/local/lib/python3.9/site-packages/hetzner/robot.py", line 391, in __iter__
    return iter([Server(self.conn, s) for s in self.conn.get('/server')])
  File "/usr/local/lib/python3.9/site-packages/hetzner/robot.py", line 368, in get
    return self.request('GET', path)
  File "/usr/local/lib/python3.9/site-packages/hetzner/robot.py", line 329, in request
    response = self._request(method, path, data, headers)
  File "/usr/local/lib/python3.9/site-packages/hetzner/robot.py", line 301, in _request
    self.conn.request(method.upper(), path, data, headers)
  File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1279, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1325, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1274, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1034, in _send_output
    self.send(msg)
  File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 974, in send
    self.connect()
  File "/usr/local/lib/python3.9/site-packages/hetzner/util/http.py", line 68, in connect
    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file,
  File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1405, in wrap_socket
    return context.wrap_socket(
  File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/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)

I've found Stackoverflow threads where other people fixed this by running the python update .command files, or by modifying the ssl library's certificate validating mechanism (code below), but neither solution has fixed the issue for me.

import ssl
ssl._create_default_https_context = ssl._create_unverified_context
@mcat-ee
Copy link
Author

mcat-ee commented Feb 12, 2022

Suppressed the error by editing the http.py file with the edit here.

I don't like this fix, however if you're going to replicate it the file for editing is located here (at least on my system/py version):
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/hetzner/util/http.py

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

1 participant