【发布时间】:2019-06-21 02:49:15
【问题描述】:
在使用 Python 2.7.14 执行不同的脚本时,我不断遇到错误,似乎导致我的 OpenSSL 安装。
例如使用requests时:
requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:661)
我在:
- Python 2.7.14
- MacOS Mojave 版本 10.14.3
- 不 使用 homebrew ! (并且不希望这样做)
Mac OS 使用LibreSSL:
$ openssl version -a
LibreSSL 2.6.5
built on: date not available
platform: information not available
options: bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) blowfish(idx)
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"
$ which openssl
/usr/bin/openssl
但是,我的 Python 安装(来自源代码)都使用 OpenSSL - 两个不同的版本:
$ python2.7 -c 'import ssl; print ssl.OPENSSL_VERSION'
OpenSSL 0.9.8zh 14 Jan 2016
$ python3.7 -c 'import ssl; print(ssl.OPENSSL_VERSION)'
OpenSSL 1.1.0i 14 Aug 2018
我想更新与 Python 2.7 一起使用的 OpenSSL,而不使用 homebrew(也不是 Anaconda),并且不使用其他包,例如 pyOpenSSL。
我可以在网上找到的大多数解决方案都建议使用 homebrew,因此不要回答我的问题:
- Updating openssl in python 2.7
- https://apple.stackexchange.com/questions/126830/how-to-upgrade-openssl-in-os-x
- https://medium.com/@katopz/how-to-upgrade-openssl-8d005554401
我的 Python 版本都没有使用 homebrew 安装,我希望保持干净,以免使我的操作系统设置进一步复杂化。
考虑到安装了不同版本的 OpenSSL,我应该关注this suggestion 并将 Python 2.7 链接到较新的 OpenSSL 版本吗?
- 这是前进的最佳方式吗?
- 会出什么问题?
- 有哪些可行的替代方案?
- 任何学习在 Mac 上导航 SSL-Python-jungle 的好资源?
【问题讨论】:
-
在与SSLLabs 核对后,我认为这可能与described here 问题有关——即使the page supports TLS 1.0 应该适用于我的Python 2.7 正在使用的OpenSSL 0.9.8zh 版本?
-
“我的 Python 版本都不是使用自制软件安装的,我想保持干净,以免使我的操作系统设置进一步复杂化。” - 目前尚不清楚您现有版本的位置安装。如果无法以相同的方式安装更新版本,那么您需要手动重新编译所有内容,这肯定会使您的操作系统设置复杂化,而不仅仅是使用 homebrew 或 Anaconda。
-
从Python官方下载页面:python.org/downloads下载,使用自带的安装器安装。
标签: python macos python-2.7 ssl openssl