Python 引用旧的 SSL 版本 [英] Python referencing old SSL version
问题描述
我在一个旧的 nas 盒子上有一个 Dropbox 上传脚本,最近我收到了以下错误
I have a Dropbox upload script on an old nas box I have, recently I've been getting the following error
SSL 证书错误:[Errno 1] _ssl.c:504:错误:0D0890A1:asn1 编码例程:ASN1_verify:未知消息摘要算法
SSL certificate error: [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm
我认为这是因为 openssl 在盒子上已经过时了
I think this is due to openssl being out of date on the box
所以我下载了 openssl,从源代码构建并安装了它,现在当我运行以下命令时,它似乎已正确更新.
So I download openssl, built it from source and installed it, now when I run the following it appears to be updated correctly.
openssl version
OpenSSL 1.0.1h 5 Jun 2014
但看起来 Python 仍在引用旧版本,我该如何更新?
But it would appear Python is still referencing an old version, how would I update this?
python -c "import ssl; print ssl.OPENSSL_VERSION"
OpenSSL 0.9.7m 23 Feb 2007
推荐答案
几天后就搞定了.MAC OS X El Captian 或更高版本
Got this working after several days. MAC OS X El Captian or greater
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
sudo rm -rf "/Applications/Python 2.7"
cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm
brew uninstall python
brew uninstall openssl
brew link --force openssl
现在使用 brew 再次安装 python 和 openssl.
Now install python and openssl again using brew.
brew install openssl
brew install python --with-brewed-openssl
将以下内容添加到 MAC 上 ~/.bash_profile 中的 PATH
Add the following to the PATH in ~/.bash_profile on your MAC
vi ~/.bash_profile
export PATH=/usr/local/opt/openssl/bin:/usr/local/opt/python/libexec/bin:$PATH
重启终端
python --version (verify if it is picking up the right version)
openssl version -a (verify if it is picking up the right version)
python -c "import ssl; print ssl.OPENSSL_VERSION"
(注意:如果您安装了 Python3,则必须在内联编译器步骤中更新 print
语法)
(note: if you installed Python3, you'll have to update the print
syntax in the inline compiler step)
python -c "import ssl; print(ssl.OPENSSL_VERSION)"
应该给你最新的OPEN SSL版本
should give you the latest version OPEN SSL version
这篇关于Python 引用旧的 SSL 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!