Uploaded image for project: 'Qt Cloud'
  1. Qt Cloud
  2. CLOUD-25

python3 - CERTIFICATE_VERIFY_FAILED on windows

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • General

    Description

      ```
      Traceback (most recent call last):
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 1346, in do_open
      h.request(req.get_method(), req.selector, req.data, headers,
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1285, in request
      self._send_request(method, url, body, headers, encode_chunked)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1331, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1280, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1040, in _send_output
      self.send(msg)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 980, in send
      self.connect()
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1454, in connect
      self.sock = self._context.wrap_socket(self.sock,
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\ssl.py", line 500, in wrap_socket
      return self.sslsocket_class._create(
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\ssl.py", line 1040, in _create
      self.do_handshake()
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\ssl.py", line 1309, in do_handshake
      self._sslobj.do_handshake()
      ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:\Users\aseem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyngrok\installer.py", line 94, in install_ngrok
      download_path = _download_file(url, **kwargs)
      File "C:\Users\aseem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyngrok\installer.py", line 215, in _download_file
      response = urlopen(url, **kwargs)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 214, in urlopen
      return opener.open(url, data, timeout)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 517, in open
      response = self._open(req, data)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 534, in _open
      result = self._call_chain(self.handle_open, protocol, protocol +
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 494, in _call_chain
      result = func(*args)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 1389, in https_open
      return self.do_open(http.client.HTTPSConnection, req,
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2288.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 1349, in do_open
      raise URLError(err)
      urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)>

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:\Users\aseem\GitProjects-Work\cute-gemini\python-ngrok\run.py", line 33, in <module>
      ngrok = cute_ngrok.CuteGrok(local_server_port, ngrok_auth_token)
      File "C:\Users\aseem\GitProjects-Work\cute-gemini\python-ngrok\utilities_ngrok.py", line 12, in _init_
      ngrok.set_auth_token(self.token)
      File "C:\Users\aseem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyngrok\ngrok.py", line 133, in set_auth_token
      install_ngrok(pyngrok_config)
      File "C:\Users\aseem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyngrok\ngrok.py", line 98, in install_ngrok
      installer.install_ngrok(pyngrok_config.ngrok_path)
      File "C:\Users\aseem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyngrok\installer.py", line 98, in install_ngrok
      raise PyngrokNgrokInstallError("An error occurred while downloading ngrok from {}: {}".format(url, e))
      pyngrok.exception.PyngrokNgrokInstallError: An error occurred while downloading ngrok from https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-windows-amd64.zip: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)>
      ```

      When running the project with python3, this error happens. The original problem is not with python or any of its packages but its with the certificate store of `urllib` used in python. Apparently, a specific root certificate expired on 30.09.2022 and not all windows machines have this root certificate updated for windows certificate store.

      More details about this error can be found:

      1. [On reddit](https://www.reddit.com/r/learnpython/comments/q5fffb/windows_python_397_urllib_and_dst_root_ca_x3_lets/)
      1. [On stack overflow](https://stackoverflow.com/questions/52074590/urllib-request-urlopen-ssl-certificate-verify-failed-error-on-windows-vista/52074591#52074591)
      1. [How to update Trusted CA for windows](http://woshub.com/updating-trusted-root-certificates-in-windows-10/)

      How I solved this problem, see in comments.

      Attachments

        Activity

          People

            as33ms Aseem Shakuntal
            anttisiukola Antti Siukola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: