我有一个非常糟糕的网络,用一个MITM证书窥探每个人的集会。这意味着我需要关闭它,例如,在节点中我使用export NODE_TLS_REJECT_UNAUTHORIZED="0"
。
在Python中有类似的方法来解决这个问题吗?
假装我有安全缺陷(我就是这样)。在我的节点示例中,我只是配置了一个环境变量并完成了。这让我使用pem文件(我不知道从哪里得到)。我试着下载证书链,但没能下载到pem文件。难道真的没有更直接的方法来实现这一点吗?老实说,网络的建立方式,我认为我甚至不能只导入一个证书。
我试过用这个..。
pip3 install itsdangerous --proxy=http://proxy.me.com:80 --index-url=http://pypi.python.org/simple/
Getting page http://pypi.python.org/simple/
Could not fetch URL http://pypi.python.org/simple/: timed out
Will skip URL http://pypi.python.org/simple/ when looking for download links for itsdangerous
Cannot fetch index base URL http://pypi.python.org/simple/
仍然确认这不是一只红鲱鱼多亏了我们的代理。
此外,我还尝试添加HTTP_PROXY
和HTTPS_PROXY
,而不是命令行选项。仍然得到以下结果..。
pip3 install itsdangerous --index-url=http://pypi.python.org/simple/
...
Downloading/unpacking itsdangerous
Getting page http://pypi.python.org/simple/itsdangerous/
Could not fetch URL http://pypi.python.org/simple/itsdangerous/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
Will skip URL http://pypi.python.org/simple/itsdangerous/ when looking for download links for itsdangerous
Getting page http://pypi.python.org/simple/
Could not fetch URL http://pypi.python.org/simple/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
也可能很重要..。
pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)
发布于 2017-08-01 19:40:39
我的网络上也有同样的问题。我这么做是为了安装枕头:
pip install Pillow --trusted-host pypi.python.org --index-url=http://pypi.python.org/simple/
...and,它对我很有用。希望能帮上忙。
发布于 2016-01-05 16:05:36
当我需要忽略证书验证链时,我使用了以下代码:
import ssl
try:
_create_verified_https_context = ssl._create_default_https_context
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
# Handle target environment that doesn't support HTTPS verification. Save
# a reference to the previous method so it is still available if needed.
ssl._create_default_https_context = _create_unverified_https_context
if not hasattr(ssl, '_create_verified_https_context'):
ssl._create_verified_https_context = _create_verified_https_context
上面的代码将告诉您的python中的SSL实例忽略未经验证的错误。还可以直接修改SSL.py文件以更改行为。
您可能还想看看:https://docs.python.org/3/library/ssl.html#ssl.SSLContext
https://stackoverflow.com/questions/34615693
复制相似问题