簡體   English   中英

python easy_install 失敗,所有包的 SSL 證書錯誤

[英]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

順便說一句,在您沒有證書之前,大多數porteasy_installpip命令都會因為 ssl 錯誤而失敗。

嘗試安裝pip來進行 python 包安裝。

您可以在此處找到文檔以快速安裝和使用它。 它通常比easy_install好很多。

默認情況下,它還使用 SSL,並使用 Requests 的證書堆棧(源自 mozilla)。

您還可以在Python Packaging User Guide 中找到大量有關使用 Python 包的一般信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM