gpt4 book ai didi

python - 请求.exceptions.SSLError : Errno 185090050

转载 作者:太空狗 更新时间:2023-10-29 23:58:56 31 4
gpt4 key购买 nike

我正在尝试在 .exe 中创建 .py。在 .py 中,应用程序工作正常,但在我使用 py2exe 在 .exe 中构建它后,出现此错误:

Traceback (most recent call last):
File "filename.py", line 210, in <module>
File "requests\api.pyc", line 55, in get
File "requests\api.pyc", line 44, in requests
File "requests\sessions.pyc", line 461, in request
File "requests\sessions.pyc", line 567, in send
File "requests\adapters.pyc", line 399, in send
requests.exceptions.SLLError: [Errno 185090050] _ssl.c:344: error: 0B084002:x509 certificate routines: X509_load_cert_crl_file:system lib

文件中的第210行是这样的

r2 = requests.get('https://www.hitbox.tv/api/chat/servers', timeout=timeoutDefault)

setup.py 是这样的:

from distutils.core import setup
import py2exe

setup(console=['filename.py'])

我该如何解决这个问题?

最佳答案

requests 模块(或者实际上是它下面的 urllib3)无法打开 CA 证书文件。

如果不想验证服务器的证书,可以将调用改为:

r2 = requests.get('https://www.hitbox.tv/api/chat/servers', 
timeout=timeoutDefault, verify=False)

如果您关心证书(并且您应该关心),请确保 CA 证书文件与您的应用程序捆绑在一起。根据 requests 文档:

You can also pass verify the path to a CA_BUNDLE file for private certs. You can also set the REQUESTS_CA_BUNDLE environment variable.

Requests can also ignore verifying the SSL certificate if you set verify to False.

参见此处:http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification

关于python - 请求.exceptions.SSLError : Errno 185090050,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24973326/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com