Python引用旧的SSL版本 [英] Python referencing old SSL version

查看:404
本文介绍了Python引用旧的SSL版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个旧的nas盒上有一个Dropbox上传脚本,最近我遇到了以下错误

I have a Dropbox upload script on an old nas box I have, recently I've been getting the following error

SSL证书错误:[错误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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆