Ruby使用错误版本的openssl [英] Ruby using wrong version of openssl

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

问题描述

 $ brew install openssl
Warning: openssl-1.0.2a-1 already installed
 $ openssl version
OpenSSL 0.9.8zd 8 Jan 2015
 $ ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
OpenSSL 1.0.1j 15 Oct 2014
 $ rvm -v
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

我发现openssl版本之间存在很多差异. Homebrew认为它在1.0.2a-1上,openssl认为它在0.9.8zd上,而Ruby认为它在1.0.1j上.我什至都不知道其中任何一个实际上是最新的!

I'm seeing a lot of discrepancies between the versions of openssl. Homebrew thinks it's on 1.0.2a-1, openssl itself thinks it's on 0.9.8zd, and Ruby thinks it's on 1.0.1j. I don't even know if any of these are actually up-to-date!

如何解决此差异并让Ruby使用正确版本的OpenSSL?它使用了错误的版本,这使我无法使用安全的API.

How can I resolve this discrepancy and get Ruby to use the correct version of OpenSSL? The fact that it's using the wrong version is stopping me from using secure APIs.

推荐答案

使用HomeBrew安装OpenSSL不会立即将其链接为默认的OpenSSL.

Installing OpenSSL with HomeBrew will not immediately link it as the default OpenSSL.

首先,让我们检查一下您使用的版本(15年7月10日,最新版本为 1.0.2d ):

First, let's check which version are you using (on Jul 10, '15 the latest version is 1.0.2d):

openssl version -a
which openssl
ruby -r openssl -e 'puts OpenSSL::OPENSSL_VERSION'

现在,确保将OpenSSL升级到最新版本:

Now, let's be sure to upgrade OpenSSL to the latest version:

brew update
brew install openssl
brew unlink openssl
brew link --force openssl

如果再次运行初始检查,则应该看到前两个指向新安装的OpenSSL.自从它被编译后,Ruby很可能仍会指向旧版本.

If you run the initial checks again, you should see the first 2 pointing to the newly installed OpenSSL. Ruby will most likely still point to the old one since it was compiled with it.

如果它指向旧版本,让我们重新编译Ruby并将其指向新版本.并且只是为了确保它将使用正确的版本,让我们传递OpenSSL前缀-尽管由于我们链接了自制软件的OpenSSL,所以不需要使用该前缀.

If it is pointing to the old version, let's recompile Ruby and point it to the new one. And just to be sure that it will use the correct version, let's pass the OpenSSL prefix -- although this shouldn't be needed since we linked homebrew's OpenSSL.

rvm get stable
rvm install ruby-2.1.6 --with-openssl-dir=`brew --prefix openssl`

(如果您已经在使用2.1.6,则为rvm reinstall)

(or rvm reinstall if you're already using 2.1.6)

这应该做到.

这篇关于Ruby使用错误版本的openssl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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