Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby找不到新版本的OpenSSL_Ruby_Macos_Openssl_Activesupport - Fatal编程技术网

Ruby找不到新版本的OpenSSL

Ruby找不到新版本的OpenSSL,ruby,macos,openssl,activesupport,Ruby,Macos,Openssl,Activesupport,OpenSSL::OpenSSL\u版本号何时何地设置?为什么不设置为我刚刚安装的最新OpenSSL 首先是错误: 如果我直接进入irb,我可以看到Ruby正在使用“旧”openssl: 这告诉我Ruby没有找到我刚刚构建的OpenSSL的本地版本,它至少应该是0x908000。有关守则: # file: usr/lib/ruby/2.0.0/openssl/digest.rb ... alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1)

OpenSSL::OpenSSL\u版本号
何时何地设置?为什么不设置为我刚刚安装的最新OpenSSL

首先是错误:

如果我直接进入irb,我可以看到Ruby正在使用“旧”openssl:

这告诉我Ruby没有找到我刚刚构建的OpenSSL的本地版本,它至少应该是0x908000。有关守则:

# file: usr/lib/ruby/2.0.0/openssl/digest.rb
...
alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1)
if OPENSSL_VERSION_NUMBER > 0x00908000
  alg += %w(SHA224 SHA256 SHA384 SHA512)
end
解释了为什么找不到SHA512

但是我不知道为什么Ruby使用老版本的OpenSSL。我使用新的源代码构建了OpenSSL和Ruby

SANDBOX=/Users/me/sandboxes/ruby2
PATH=$(SANDBOX)/usr/bin:$(PATH)

# Create a fresh OpenSSL from sources
(downloaded and unpacked http://www.openssl.org/source/openssl-1.0.1e.tar.gz)
$ ./config --prefix=$(SANDBOX)/usr --openssldir=$(SANDBOX)/usr/openssl
$ make ; make install ; make clean
# verify openssl
$ which openssl
/Users/me/sandboxes/ruby2/usr/bin/openssl
$ openssl version
OpenSSL 1.0.1e 11 Feb 2013

# Create a fresh Ruby from sources
(download and unpack http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz)
$ ./configure --prefix=$(SANDBOX)/usr --with-open-ssl-dir=$(SANDBOX)/usr/openssl
$ make ; make intalll ; make clean
# verify ruby
$ which ruby
/Users/me/sandboxes/ruby2/usr/bin/ruby
但是这个ruby似乎找不到我刚刚构建的openssl 1.0.1e

我的理解是,
-
/configure
-with open ssl dir
参数对于告诉ruby使用新的OpenSSL是必要的和足够的,但这似乎不起作用

关于如何让Ruby识别我构建的新OpenSSL有什么想法吗


我试过运行
rubyextconf.rb;制作按照@Gaurish(下面)的建议进行安装,但仍然可以在系统中找到安装的OpenSSL,而不是在我的项目根目录中。

结果是,要使用Ruby on Ubuntu编译和安装OpenSSL,在安装Ruby之后,需要遵循以下步骤:


让我知道它是否有效

我认为传递到
/configure
的正确标志是
--使用openssl目录
,而不是
--使用openssl目录

另外,在这种情况下,使用openssl dir传递给
--的正确值是
$SANDBOX/usr
,而不是
$SANDBOX/usr/openssl

此外,您可能需要为64位体系结构编译OpenSSL

这个过程对我很有用(OS X 10.8):


旧问题,但如果您必须处理旧设置,则仍然相关:

在我的例子中,问题在于OpenSSL安装。 如上所述,您必须确保使用OpenSSL安装共享库:

$ ./config --prefix=/path/to/openssl-0.9.8g shared
$ make depend
$ make
$ make install
然后像往常一样安装OpenSSL

对于ruby,我使用了以下配置行:

$ ./configure --prefix=/path/to/ruby-2.2.2/ --with-openssl-dir=/path/to/openssl-0.9.8g
$ make
$ make install
结果:

$ /path/to/ruby-2.2.2/bin/irb
irb(main):001:0> require "openssl"
=> true
irb(main):002:0> OpenSSL::Digest.new('sha512')
=> #<OpenSSL::Digest: cf83e13000efb8bd00042850d66d8007d620e4050b0005dc83f4a921d36ce00047d0d13c5d85f2b0ff8318d2877eec2f000931bd47417a81a538327af927da3e>
$/path/to/ruby-2.2.2/bin/irb
irb(主):001:0>需要“openssl”
=>正确
irb(main):002:0>OpenSSL::Digest.new('sha512'))
=> #
TL;DR 当OpenSSL发生更改时,请始终重新编译Ruby或OpenSSL本机扩展

为什么? Ruby将OpenSSL版本编译为OpenSSL本机扩展,即使它链接到共享的OpenSSL库。重新安装Ruby或重新编译openssl扩展来修复它

$ ruby -ropenssl -e'puts OpenSSL::OPENSSL_VERSION'
OpenSSL 1.0.2e 3 Dec 2015
$ /usr/local/opt/openssl/bin/openssl version
OpenSSL 1.0.2g  1 Mar 2016
$ strings {{redacted}/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle | grep '1.0.2'
OpenSSL 1.0.2e 3 Dec 2015
$ otool -L {{redacted}}/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle
{{redacted}}/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle:
        {{redacted}}/ruby-2.3.0/lib/libruby.2.3.0.dylib (compatibility version 2.3.0, current version 2.3.0)
        /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
        /usr/local/opt/gmp/lib/libgmp.10.dylib (compatibility version 14.0.0, current version 14.0.0)
        /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
我们使用和。我们不使用
/opt/rubies
,而是使用
/usr/local/rubies
来避免
sudo
。如果您不想为chruby设置rubies,也可以
sudo ln-s/usr/local/rubies/opt/rubies

brew install openssl && \
ruby-install ruby-2.3.0 \
  --no-install-deps \
  -- \
  --without-X11 \
  --without-tk \
  --enable-shared \
  --disable-install-doc \
  --with-openssl-dir="$(brew --prefix openssl)"
更新 还有一个常量是从实际加载的OpenSSL库中派生出来的

用于mac的OpenSSL::OpenSSL库版本


sudogem安装openssl--install dir vendor/bundle--with openssl dir=/usr/local/cillar/openssl@1.1/1.1.1k

它似乎工作正常(它创建了一个新的openssl.bundle),但没有乐趣:
openssl::openssl\u版本号。to\u s(16)
仍然报告
“9070cf”
,SHA512不可用。问题:mkmf如何知道在哪里查找库?我不需要告诉它在$(SANDBOX)而不是默认系统库中查找吗?顺便说一下,我注意到我有$(SANDBOX)/usr/lib/libssl.a,但没有libssl.dylib——这是意料之中的吗?你做得很艰难
apt get install libssl dev
,编译Ruby,它将自动构建openssl(ossl)扩展。好吧,也许是个愚蠢的问题,但是您是否尝试了使用openssl dir
而不是使用openssl dir
?omg<代码>配置:警告:无法识别的选项:-使用openssl dir
我在
/configure
中有一个视图,此脚本无法识别此选项,因此我使用了
-和opt dir=
这对我很有效!但是使用gem再次陷入陷阱,所以最后我用
/opt/rubies/ruby-2.0.0-p0/bin:$PATH:
否决了
PATH=/usr/bin:$PATH
,它由
brew安装
制成,现在运行良好-服务器正在运行。感谢您在此处提供的提示:)感谢您提供有关使用opt dir的
--的提示!使用更简单。我仍然无法配置openssl。它不会被安装。我没有尝试过,但你的解释很清楚,说明了原因。因此,除非有人说答案是错的,否则你会得到复选标记。谢谢。您可能也应该使用RPATH。
$ ./config --prefix=/path/to/openssl-0.9.8g shared
$ make depend
$ make
$ make install
$ ./configure --prefix=/path/to/ruby-2.2.2/ --with-openssl-dir=/path/to/openssl-0.9.8g
$ make
$ make install
$ /path/to/ruby-2.2.2/bin/irb
irb(main):001:0> require "openssl"
=> true
irb(main):002:0> OpenSSL::Digest.new('sha512')
=> #<OpenSSL::Digest: cf83e13000efb8bd00042850d66d8007d620e4050b0005dc83f4a921d36ce00047d0d13c5d85f2b0ff8318d2877eec2f000931bd47417a81a538327af927da3e>
$ ruby -ropenssl -e'puts OpenSSL::OPENSSL_VERSION'
OpenSSL 1.0.2e 3 Dec 2015
$ /usr/local/opt/openssl/bin/openssl version
OpenSSL 1.0.2g  1 Mar 2016
$ strings {{redacted}/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle | grep '1.0.2'
OpenSSL 1.0.2e 3 Dec 2015
$ otool -L {{redacted}}/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle
{{redacted}}/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle:
        {{redacted}}/ruby-2.3.0/lib/libruby.2.3.0.dylib (compatibility version 2.3.0, current version 2.3.0)
        /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
        /usr/local/opt/gmp/lib/libgmp.10.dylib (compatibility version 14.0.0, current version 14.0.0)
        /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
brew install openssl && \
ruby-install ruby-2.3.0 \
  --no-install-deps \
  -- \
  --without-X11 \
  --without-tk \
  --enable-shared \
  --disable-install-doc \
  --with-openssl-dir="$(brew --prefix openssl)"