在 python 2.7 中更新 openssl [英] Updating openssl in python 2.7

查看:41
本文介绍了在 python 2.7 中更新 openssl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道是否有人可以解释 openssl 在 python2.7 中的工作原理.我不确定 python 是否有自己的 openssl 或从本地机器/环境中获取它?

让我解释一下:(如果我在 Python 中这样做)

<预><代码>>>>导入 ssl>>>ssl.OPENSSL_VERSION'OpenSSL 0.9.8x 2012 年 5 月 10 日'

(在终端)

$ openssl 版本OpenSSL 0.9.8x 2012 年 5 月 10 日$ which openssl/usr/bin/openssl

现在我更新了 openssl(已下载.)

$ cd openssl-1.0.1c$ ./Configure darwin64-x86_64-cc --prefix=/usr --openssldir=/opt/local/etc/openssl 共享$ make$ sudo 安装

这创建了单独的导演(如指定),所以我将其复制到旧路径

cp -f/usr/local/ssl/bin/openssl/usr/bin/openssl

现在在终端 openssl 版本已经更新但不是来自 python!

$ openssl 版本OpenSSL 1.0.1c 2012 年 5 月 10 日

我确实注意到 .dylib 仍然指向旧版本,我该如何更改?

$ ls -l/usr/lib/*ssl*-rwxr-xr-x 1 根轮 411680 2012 年 7 月 17 日/usr/lib/libssl.0.9.7.dylib-rwxr-xr-x 1 根轮 602800 5 月 24 日 03:43/usr/lib/libssl.0.9.8.dylib-rwxr-xr-x 1 根轮 390908 Sep 9 17:37/usr/lib/libssl.1.0.0.dyliblrwxr-xr-x 1 根轮 2012 年 7 月 17 日 18 日/usr/lib/libssl.dylib ->libssl.0.9.8.dylib

更新:我更改了链接,python 中仍然有旧版本.

$ ls -l/usr/lib/*ssl*-rwxr-xr-x 1 根轮 411680 2012 年 7 月 17 日/usr/lib/libssl.0.9.7.dylib-rwxr-xr-x 1 根轮 602800 5 月 24 日 03:43/usr/lib/libssl.0.9.8.dylib-rwxr-xr-x 1 根轮 390908 Sep 9 17:37/usr/lib/libssl.1.0.0.dyliblrwxr-xr-x 1 根轮 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 上通过 homebrew 将 openssl 升级到 1.0.1j 后,但系统 python 仍然指的是旧版本 0.9.8.原来python指的是openssl.所以我用 brewed openssl 安装了新的 python 并在 Mac 上完成了这个问题,还不是 Ubuntu.

在 Mac OS X 版本 10.10 和系统 python 版本 2.7.6 上,我的程序如下:

$ brew 更新$ brew install openssl

然后就可以看到openssl 1.0.1j版本了.

$ brew link openssl --force$ brew install python --with-brewed-openssl

你必须用 brewed openssl 安装新的 python.然后,你可以看到/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 拥有,而不是由 Ryan 告诉的 root 拥有,但我使用了 'sudo'.而且,在此指令之前,我没有/usr/local/bin/python.完成此说明后,您可以使用 python 版本 2.7.8 而不是 2.7.6.

最后,您可以看到如下内容;

$ python --version蟒蛇 2.7.8$ python -c导入ssl;打印ssl.OPENSSL_VERSION"OpenSSL 1.0.1j 2014 年 10 月 15 日

直到现在,我都在 Ubuntu 12.04 上工作.如果我有 Ubuntu 12.04 的解决方案,那么我会更新我的答案.我希望这个过程对你有帮助.

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?

let me explain: (if I do this in Python)

>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8x 10 May 2012'

(In terminal)

$ openssl version
OpenSSL 0.9.8x 10 May 2012
$ which openssl 
/usr/bin/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

now in terminal openssl version has been updated but not from python!

$ openssl version
OpenSSL 1.0.1c 10 May 2012

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

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

解决方案

Please refer to http://rkulla.blogspot.kr/2014/03/the-path-to-homebrew.html

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.

On Mac OS X version 10.10 and system python version 2.7.6, my procedure is as follows:

$ brew update

$ brew install openssl

Then you can see openssl version 1.0.1j.

$ brew link openssl --force 

$ brew install python --with-brewed-openssl    

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

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

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屋!

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