Skip to content

SSL Certificates Issue - 'CERTIFICATE_VERIFY_FAILED' #49

@mcat-ee

Description

@mcat-ee

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/python@3.9/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/python@3.9/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/python@3.9/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/python@3.9/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/python@3.9/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/python@3.9/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/python@3.9/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/python@3.9/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/python@3.9/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions