[英]Easy_install or pip install error : [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)]
[英]python easy_install fails with SSL certificate error for all packages
目标:我使用 RedHat 5 并尝试为 Web 应用程序安装最新的 python 和 django。
我成功地安装了 python27 和 easy_install,并使用 openssl 安装了 wget。
问题:但是,现在我尝试从 pypi.python.org 获取任何内容,但出现以下错误:
$ sudo easy_install --verbose django
Searching for django
Reading https://pypi.python.org/simple/django/
Download error on https://pypi.python.org/simple/django/: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed -- Some packages may not be found!
Couldn't find index page for 'django' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed -- Some packages may not be found!
No local packages or download links found for django
error: Could not find suitable distribution for Requirement.parse('django')
我尝试使用 openssl s_client -showcert -connect 查找 pypi.python.org 的证书,但不知道如何处理它,将它存储在哪里。 谷歌上的信息不多,需要专家帮助。
谢谢!
编辑:我的意思是 wget* 和 openssl。
$ wget http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
$ tar -xzf wget-1.15.tar.gz
$ cd wget-1.15
$ ./configure --with-ssl=openssl
$ make
$ sudo make install
我也无法让 wget 拉出页面:
$ wget https://pypi.python.org/simple/django/
--2014-01-21 11:18:45-- https://pypi.python.org/simple/django/
Resolving pypi.python.org (pypi.python.org)... 199.27.73.185, 199.27.74.184
Connecting to pypi.python.org (pypi.python.org)|199.27.73.185|:443... connected.
ERROR: cannot verify pypi.python.org's certificate, issued by ‘/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance CA-3’:
Unable to locally verify the issuer's authority.
To connect to pypi.python.org insecurely, use `--no-check-certificate'.
您的 curl 证书太旧了尝试下载新的 curl 证书:
sudo wget http://curl.haxx.se/ca/cacert.pem -O /etc/pki/tls/certs/ca-bundle.crt
在寻找此问题的解决方案后,我找到了此页面。 如果其他人有类似的问题,我找到的解决方案是:
在setuptools/ssl_support.py
文件(由 easy_install 使用,在 egg 文件中: ./lib/python2.7/site-packages/setuptools-3.5.1-py2.7.egg
)的./lib/python2.7/site-packages/setuptools-3.5.1-py2.7.egg
,证书包文件硬编码在cert_paths
变量中:
cert_paths = """
/etc/pki/tls/certs/ca-bundle.crt
/etc/ssl/certs/ca-certificates.crt
/usr/share/ssl/certs/ca-bundle.crt
/usr/local/share/certs/ca-root.crt
...etc..
"""
easy_install
将使用此列表中存在的第一个文件,因为它调用find_ca_bundle
。 如果此证书捆绑文件中的证书已过期,则 easy_install 将失败并显示此 SSL 错误。 因此需要更新该证书文件或更改cert_paths
在这个ssl_support.py
文件,以点到本地了最新的证书捆绑文件。
我在特定环境中看到过这个问题:带有 macports 的 Mac OS X,在用户的本地路径中安装软件包。 解决方案是从 curl 安装证书:
port install curl-ca-bundle
顺便说一句,在您没有证书之前,大多数port
、 easy_install
和pip
命令都会因为 ssl 错误而失败。
尝试安装pip
来进行 python 包安装。
您可以在此处找到文档以快速安装和使用它。 它通常比easy_install
好很多。
默认情况下,它还使用 SSL,并使用 Requests 的证书堆栈(源自 mozilla)。
您还可以在Python Packaging User Guide 中找到大量有关使用 Python 包的一般信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.