Pyngrok: 在下载ngrok时SSL证书验证失败

huangapple go评论90阅读模式
英文:

Pyngrok: SSL certificate verify failed while downloading ngrok

问题

我想隧道化我的FastAPI服务器,所以我使用poetry安装了pyngrok,并创建/激活了虚拟环境。

这是我的pyproject.toml文件:

[tool.poetry.dependencies]
python = "^3.11"
fastapi = "^0.100.1"
uvicorn = "^0.23.2"
pyngrok = "^6.0.0"
httpx = "^0.24.1"

然后在虚拟环境中运行了以下命令:ngrok http 9000,并收到了以下错误消息:

Traceback (most recent call last):
  File "C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  ...
pyngrok.exception.PyngrokNgrokInstallError: An error occurred while downloading ngrok from https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-windows-amd64.zip: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)>

我尝试在浏览器中打开了链接https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-windows-amd64.zip,并成功下载了zip文件,我可以打开它并运行ngrok.exe,但这没有解决问题。有没有办法解决这个问题?

英文:

I want to tunnel my FastAPI server, so I installed pyngrok using poetry and created/activated virtual env.

Here is my pyproject.toml:

[tool.poetry.dependencies]
python = &quot;^3.11&quot;
fastapi = &quot;^0.100.1&quot;
uvicorn = &quot;^0.23.2&quot;
pyngrok = &quot;^6.0.0&quot;
httpx = &quot;^0.24.1&quot;

Then in virtual env I run command: ngrok http 9000 and get such error:

Traceback (most recent call last):
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py&quot;, line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\http\client.py&quot;, line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\http\client.py&quot;, line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\http\client.py&quot;, line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\http\client.py&quot;, line 1037, in _send_output
    self.send(msg)
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\http\client.py&quot;, line 975, in send
    self.connect()
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\http\client.py&quot;, line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\ssl.py&quot;, line 517, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\ssl.py&quot;, line 1075, in _create
    self.do_handshake()
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\ssl.py&quot;, line 1346, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;C:\Users\sergey\AppData\Local\pypoetry\Cache\virtualenvs\fast-api-telegram-bot-a-NRO46l-py3.11\Lib\site-packages\pyngrok\installer.py&quot;, line 117, in install_ngrok
    download_path = _download_file(url, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\sergey\AppData\Local\pypoetry\Cache\virtualenvs\fast-api-telegram-bot-a-NRO46l-py3.11\Lib\site-packages\pyngrok\installer.py&quot;, line 261, in _download_file
    response = urlopen(url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py&quot;, line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py&quot;, line 519, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py&quot;, line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py&quot;, line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py&quot;, line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\sergey\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py&quot;, line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: &lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)&gt;

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;&lt;frozen runpy&gt;&quot;, line 198, in _run_module_as_main
  File &quot;&lt;frozen runpy&gt;&quot;, line 88, in _run_code
  File &quot;C:\Users\sergey\AppData\Local\pypoetry\Cache\virtualenvs\fast-api-telegram-bot-a-NRO46l-py3.11\Scripts\ngrok.exe\__main__.py&quot;, line 7, in &lt;module&gt;
  File &quot;C:\Users\sergey\AppData\Local\pypoetry\Cache\virtualenvs\fast-api-telegram-bot-a-NRO46l-py3.11\Lib\site-packages\pyngrok\ngrok.py&quot;, line 527, in main
    run(sys.argv[1:])
  File &quot;C:\Users\sergey\AppData\Local\pypoetry\Cache\virtualenvs\fast-api-telegram-bot-a-NRO46l-py3.11\Lib\site-packages\pyngrok\ngrok.py&quot;, line 513, in run
    install_ngrok(pyngrok_config)
  File &quot;C:\Users\sergey\AppData\Local\pypoetry\Cache\virtualenvs\fast-api-telegram-bot-a-NRO46l-py3.11\Lib\site-packages\pyngrok\ngrok.py&quot;, line 100, in install_ngrok
    installer.install_ngrok(pyngrok_config.ngrok_path, pyngrok_config.ngrok_version)
  File &quot;C:\Users\sergey\AppData\Local\pypoetry\Cache\virtualenvs\fast-api-telegram-bot-a-NRO46l-py3.11\Lib\site-packages\pyngrok\installer.py&quot;, line 121, in install_ngrok
    raise PyngrokNgrokInstallError(&quot;An error occurred while downloading ngrok from {}: {}&quot;.format(url, e))
pyngrok.exception.PyngrokNgrokInstallError: An error occurred while downloading ngrok from https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-windows-amd64.zip: &lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)&gt;

I tried to open link https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-windows-amd64.zip from traceback in browser and it dowloaded zip, I can open it and run ngrok.exe but that didn't help. Any way to solve this?

答案1

得分: 1

只需从官方网站下载ngrok.exe,将其放入您的应用程序目录,并运行命令ngrok http 9000

英文:

Just download ngrok.exe from official website, place it in your application directory and run command ngrok http 9000.

huangapple
  • 本文由 发表于 2023年8月4日 06:40:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76831986.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定