在python 2.7中更新openssl [英] Updating openssl in python 2.7
问题描述
想知道是否有人可以解释openssl在python2.7中是如何工作的. 我不确定python是否拥有自己的openssl或从本地计算机/环境中获取它?
wondering if someone may please explain how openssl works in python2.7. I'm not sure if python got its own openssl or picks it up from local machine/env?
让我解释一下: (如果我在Python中执行此操作)
let me explain: (if I do this in Python)
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8x 10 May 2012'
(在终端中)
$ openssl version
OpenSSL 0.9.8x 10 May 2012
$ which openssl
/usr/bin/openssl
现在我更新了openssl(已下载.)
now I updated openssl (downloaded .)
$ cd openssl-1.0.1c
$ ./Configure darwin64-x86_64-cc --prefix=/usr --openssldir=/opt/local/etc/openssl shared
$ make
$ sudo make install
这会创建单独的导演(如指定),因此我将其复制到了旧路径
this created separate director(as specified), so I copied it to the old path
cp -f /usr/local/ssl/bin/openssl /usr/bin/openssl
现在终端opensl版本已更新,但不是python版本!
now in terminal openssl version has been updated but not from python!
$ openssl version
OpenSSL 1.0.1c 10 May 2012
我确实注意到.dylib仍指向旧版本,该如何更改?
I did noticed that .dylib is still pointing to old version, how can I change this?
$ ls -l /usr/lib/*ssl*
-rwxr-xr-x 1 root wheel 411680 Jul 17 2012 /usr/lib/libssl.0.9.7.dylib
-rwxr-xr-x 1 root wheel 602800 May 24 03:43 /usr/lib/libssl.0.9.8.dylib
-rwxr-xr-x 1 root wheel 390908 Sep 9 17:37 /usr/lib/libssl.1.0.0.dylib
lrwxr-xr-x 1 root wheel 18 Jul 17 2012 /usr/lib/libssl.dylib -> libssl.0.9.8.dylib
更新 :我更改了python上的链接仍为旧版本.
Update: I changed the link still got old version at python.
$ ls -l /usr/lib/*ssl*
-rwxr-xr-x 1 root wheel 411680 Jul 17 2012 /usr/lib/libssl.0.9.7.dylib
-rwxr-xr-x 1 root wheel 602800 May 24 03:43 /usr/lib/libssl.0.9.8.dylib
-rwxr-xr-x 1 root wheel 390908 Sep 9 17:37 /usr/lib/libssl.1.0.0.dylib
lrwxr-xr-x 1 root wheel 18 Sep 11 15:47 /usr/lib/libssl.dylib -> libssl.1.0.0.dylib
推荐答案
请参考 http://rkulla.blogspot.kr/2014/03/the-path-to-homebrew.html
在MAC上通过自制软件将openssl升级到1.0.1j之后,但是系统python仍然引用旧版本0.9.8.原来被称为openssl的python.因此,我用酿造的openssl安装了新的python,并在Mac(尚未安装Ubuntu)上解决了此问题.
After upgrading openssl to 1.0.1j by homebrew on MAC, but system python still referred to old version 0.9.8. It turned out the python referred to openssl. So I have installed new python with brewed openssl and finished this issue on Mac, not yet Ubuntu.
在Mac OS X 10.10版和系统python 2.7.6版上,我的过程如下:
On Mac OS X version 10.10 and system python version 2.7.6, my procedure is as follows:
$ brew update
$ brew install openssl
然后您可以看到openssl版本1.0.1j.
Then you can see openssl version 1.0.1j.
$ brew link openssl --force
$ brew install python --with-brewed-openssl
您必须使用酿造的openssl安装新的python.然后,您可以看到/usr/local/Cellar/python/2.7.8_2/bin/python.
You have to install new python with brewed openssl. Then, you can see /usr/local/Cellar/python/2.7.8_2/bin/python.
$ sudo ln -s /usr/local/Cellar/python/2.7.8_2/bin/python /usr/local/bin/python
当然,/usr/local/*应该由$ USER拥有,而不是root,这是Ryan告诉的,但是我使用了'sudo'.而且,在执行此指令之前,我没有/usr/local/bin/python.完成此说明后,您可以使用python版本2.7.8而不是2.7.6.
Of course, /usr/local/* should be owned by $USER, not root, which is told by Ryan, but I used 'sudo'. And, before this instruction, I didn't have /usr/local/bin/python. After this instruction, you can use python version 2.7.8 not 2.7.6.
最后,您可以看到以下内容;
Finally, you can see as belows;
$ python --version
Python 2.7.8
$ python -c "import ssl; print ssl.OPENSSL_VERSION"
OpenSSL 1.0.1j 15 Oct 2014
到目前为止,我正在Ubuntu 12.04上进行开发.如果我有适用于Ubuntu 12.04的解决方案,那么我将更新答案.希望此过程对您有所帮助.
Till now, I'm working on it on Ubuntu 12.04. If I have a solution for Ubuntu 12.04, then I will update my answer. I hope this procedure help you.
这篇关于在python 2.7中更新openssl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!