【问题标题】:Trouble with OpenSSL on RHEL 6.3 and all Ruby installersRHEL 6.3 和所有 Ruby 安装程序上的 OpenSSL 问题
【发布时间】:2014-04-14 05:41:13
【问题描述】:

在我们的 RHEL 6.3 系统上安装任何版本的 Ruby 时,OpenSSL 似乎无法正确编译。我一直试图让用户安装 RVM 并通过 ruby​​-install 和 chruby 用 root 安装替换它们。 OpenSSL 在我们的 RVM 用户安装(使用规定的 RVM 修复)以及在 /usr/bin 的 Ruby 1.8.7 的内置系统安装中运行良好。

OpenSSL 在我使用 ruby​​-install、ruby-build 甚至 RVM 尝试过的每个 Ruby 版本中都被破坏,当使用他们最新的建议修复时。 1.9.3-p392(我们的 prod 版本)、最新的 1.9 和当前的 2.1.0。我已经尝试了所有可以找到的 openssl 修复/解决方法,例如指向各种 openssl 文件夹的 --with-openssl-dir=/some/dir 配置,但对我没有任何作用。

以下是我多次尝试中的一些相关信息:

[root@dbatcit ~]# ruby-install ruby
>>> Installing ruby 2.1.0 into /opt/rubies/ruby-2.1.0 ...
>>> Installing dependencies for ruby 2.1.0 ...
Loaded plugins: product-id, rhnplugin, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Package gcc-4.4.7-4.el6.x86_64 already installed and latest version
Package automake-1.11.1-4.el6.noarch already installed and latest version
Package zlib-devel-1.2.3-29.el6.x86_64 already installed and latest version
Package libyaml-devel-0.1.3-1.el6.x86_64 already installed and latest version
Package openssl-devel-1.0.1e-16.el6_5.4.x86_64 already installed and latest version
Package gdbm-devel-1.8.0-36.el6.x86_64 already installed and latest version
Package readline-devel-6.0-4.el6.x86_64 already installed and latest version
Package ncurses-devel-5.7-3.20090208.el6.x86_64 already installed and latest version
Package libffi-devel-3.0.5-3.2.el6.x86_64 already installed and latest version
Nothing to do
.
.
make[2]: Entering directory `/usr/local/src/ruby-2.1.0/ext/openssl'
compiling ossl_pkey.c
compiling ossl_ssl.c
ossl_ssl.c:121: error: âTLSv1_2_methodâ undeclared here (not in a function)
ossl_ssl.c:122: error: âTLSv1_2_server_methodâ undeclared here (not in a function)
ossl_ssl.c:123: error: âTLSv1_2_client_methodâ undeclared here (not in a function)
ossl_ssl.c:127: error: âTLSv1_1_methodâ undeclared here (not in a function)
ossl_ssl.c:128: error: âTLSv1_1_server_methodâ undeclared here (not in a function)
ossl_ssl.c:129: error: âTLSv1_1_client_methodâ undeclared here (not in a function)
make[2]: *** [ossl_ssl.o] Error 1
make[2]: Leaving directory `/usr/local/src/ruby-2.1.0/ext/openssl'
make[1]: *** [ext/openssl/all] Error 2
make[1]: Leaving directory `/usr/local/src/ruby-2.1.0'
make: *** [build-ext] Error 2
!!! Compiling ruby 2.1.0 failed!



[root@dbatcit ~]# ruby-install ruby 1.9
>>> Installing ruby 1.9.3-p484 into /opt/rubies/ruby-1.9.3-p484 ...
>>> Installing dependencies for ruby 1.9.3-p484 ...
Loaded plugins: product-id, rhnplugin, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Package gcc-4.4.7-4.el6.x86_64 already installed and latest version
Package automake-1.11.1-4.el6.noarch already installed and latest version
Package zlib-devel-1.2.3-29.el6.x86_64 already installed and latest version
Package libyaml-devel-0.1.3-1.el6.x86_64 already installed and latest version
Package openssl-devel-1.0.1e-16.el6_5.4.x86_64 already installed and latest version
Package gdbm-devel-1.8.0-36.el6.x86_64 already installed and latest version
Package readline-devel-6.0-4.el6.x86_64 already installed and latest version
Package ncurses-devel-5.7-3.20090208.el6.x86_64 already installed and latest version
Package libffi-devel-3.0.5-3.2.el6.x86_64 already installed and latest version
Nothing to do
.
.
make[2]: Entering directory `/usr/local/src/ruby-1.9.3-p484/ext/openssl'
compiling ossl_pkey.c
compiling ossl_ssl.c
compiling ossl_pkcs12.c
compiling ossl_bn.c
compiling ossl_hmac.c
ossl_hmac.c: In function âossl_hmac_copyâ:
ossl_hmac.c:90: warning: implicit declaration of function âHMAC_CTX_copyâ
compiling ossl_asn1.c
compiling ossl.c
compiling ossl_bio.c
compiling ossl_pkey_rsa.c
compiling ossl_ocsp.c
ossl_ocsp.c: In function âossl_ocspreq_add_certidâ:
ossl_ocsp.c:180: warning: function called through a non-compatible type
ossl_ocsp.c:180: note: if this code is reached, the program will abort
ossl_ocsp.c: In function âossl_ocspreq_get_certidâ:
ossl_ocsp.c:200: warning: function called through a non-compatible type
ossl_ocsp.c:200: note: if this code is reached, the program will abort
ossl_ocsp.c: In function âossl_ocspbres_get_statusâ:
ossl_ocsp.c:541: warning: function called through a non-compatible type
ossl_ocsp.c:541: note: if this code is reached, the program will abort
compiling ossl_pkey_dh.c
ossl_pkey_dh.c: In function âossl_dh_initializeâ:
ossl_pkey_dh.c:184: warning: function called through a non-compatible type
ossl_pkey_dh.c:184: note: if this code is reached, the program will abort
ossl_pkey_dh.c: In function âossl_dh_to_public_keyâ:
ossl_pkey_dh.c:372: warning: function called through a non-compatible type
ossl_pkey_dh.c:372: note: if this code is reached, the program will abort
compiling ossl_ns_spki.c
compiling ossl_x509attr.c
compiling ossl_x509name.c
ossl_x509name.c: In function âossl_x509name_hash_oldâ:
ossl_x509name.c:342: warning: implicit declaration of function âX509_NAME_hash_oldâ
compiling ossl_pkcs7.c
compiling ossl_pkey_ec.c
ossl_pkey_ec.c: In function âossl_ec_group_initializeâ:
ossl_pkey_ec.c:784: warning: function called through a non-compatible type
ossl_pkey_ec.c:784: note: if this code is reached, the program will abort
ossl_pkey_ec.c: In function âossl_ec_group_to_stringâ:
ossl_pkey_ec.c:1154: warning: function called through a non-compatible type
ossl_pkey_ec.c:1154: note: if this code is reached, the program will abort
compiling ossl_ssl_session.c
ossl_ssl_session.c: In function âossl_ssl_session_initializeâ:
ossl_ssl_session.c:53: warning: function called through a non-compatible type
ossl_ssl_session.c:53: note: if this code is reached, the program will abort
ossl_ssl_session.c:57: warning: function called through a non-compatible type
ossl_ssl_session.c:57: note: if this code is reached, the program will abort
ossl_ssl_session.c: In function âossl_ssl_session_to_pemâ:
ossl_ssl_session.c:251: warning: function called through a non-compatible type
ossl_ssl_session.c:251: note: if this code is reached, the program will abort
compiling openssl_missing.c
compiling ossl_x509.c
compiling ossl_x509cert.c
compiling ossl_digest.c
compiling ossl_pkcs5.c
ossl_pkcs5.c: In function âossl_pkcs5_pbkdf2_hmacâ:
ossl_pkcs5.c:39: warning: implicit declaration of function âPKCS5_PBKDF2_HMACâ
compiling ossl_rand.c
compiling ossl_engine.c
compiling ossl_x509crl.c
compiling ossl_cipher.c
ossl_cipher.c: In function âossl_cipher_copyâ:
ossl_cipher.c:143: warning: implicit declaration of function âEVP_CIPHER_CTX_copyâ
compiling ossl_x509ext.c
compiling ossl_config.c
compiling ossl_x509store.c
compiling ossl_x509revoked.c
compiling ossl_pkey_dsa.c
compiling ossl_x509req.c
linking shared-object openssl.so
installing default openssl libraries
make[2]: Leaving directory `/usr/local/src/ruby-1.9.3-p484/ext/openssl'
.
.
>>> Successfully installed ruby 1.9.3-p484 into /opt/rubies/ruby-1.9.3-p484

注意上面的所有 ossl 警告。

重新启动会话。 测试系统 Ruby 1.8.7 openssl:有效。 测试 ruby​​-install Ruby 1.9.3 openssl:失败。

[root@dbatcit ~]# chruby
   ruby-1.9.3-p484
[root@dbatcit ~]# which ruby
/usr/bin/ruby
[root@dbatcit ~]# ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
[root@dbatcit ~]# ruby -ropenssl -e "puts OpenSSL::VERSION"
1.0.0
[root@dbatcit ~]# chruby 1.9
[root@dbatcit ~]# chruby
 * ruby-1.9.3-p484
[root@dbatcit ~]# which ruby
/opt/rubies/ruby-1.9.3-p484/bin/ruby
[root@dbatcit ~]# ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
[root@dbatcit ~]# ruby -ropenssl -e "puts OpenSSL::VERSION"
/opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-linux/openssl.so: undefined symbol: EC_GROUP_new_curve_GF2m - /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-linux/openssl.so (LoadError)
        from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/openssl.rb:17:in `<top (required)>'
        from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
[root@dbatcit ~]#


[root@dbatcit ~]# which -a openssl
/usr/bin/openssl
/usr/local/bin/openssl
[root@dbatcit ~]# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
[root@dbatcit ~]# /usr/local/bin/openssl version
OpenSSL 0.9.8d 28 Sep 2006

在用户主页中测试 RVM Ruby 1.9.3 openssl:工作。

[userbob@dbatcit ~]$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]
[userbob@dbatcit ~]$ ruby -ropenssl -e "puts OpenSSL::VERSION"
1.1.0
[userbob@dbatcit ~]$ which openssl
/usr/local/bin/openssl
[userbob@dbatcit ~]$ openssl version
OpenSSL 0.9.8d 28 Sep 2006
[userbob@dbatcit ~]$ .rvm/usr/bin/openssl version
OpenSSL 1.0.1c 10 May 2012

【问题讨论】:

    标签: ruby openssl rvm rhel ruby-install


    【解决方案1】:

    经过太多小时的研究,并且对 Linux 的了解远远超出了我的关心,我已将问题缩小到 RHEL 和 OpenSSL 的基本特性以及 Ruby (extconf.rb) 在安装过程中做出的错误假设。以下网站为我提供了一些关于看什么的好线索,但我没有发现任何东西能像我需要的那样把它们放在一起。

    ...并不太感谢一大堆涉及 Ruby 补丁和 EC2M 的红鲱鱼。此外,RVM 需要纠正他们的乐观态度,即他们已经使用 autolibs 解决了这个问题,并且应该恢复他们之前的 openssl 页面。

    基本解法规则

    规则 1

    安装由 yum 在/usr/bin 中创建和维护的 OpenSSL (1.0.1e) 不能用于正确编译 Ruby 的 OpenSSL 扩展——至少,目前在我的机器上没有最新版本的 Ruby (1.9 .3-p484、2.0.0、2.1.0)。 RHEL 6.3。我只能推测这是由于 RedHat 编译 OpenSSL 的特殊性,正如 OpenSSL FAQ 中所暗示的那样。

    规则 2

    我在 /usr/localbin + opensslssl/bin)中发现了两个旧版本 (0.9.8) 的 OpenSSL,更新/替换这些让我更接近解决方案。无论出于何种原因,每次在/usr/local 中手动安装 OpenSSL 1.0.1f(无论 bin、openssl、ssl 目录如何排列)都坚持将库放在/usr/local/lib64 而不是/usr/local/lib 中(除非我破解了Makefile,当然)。 Ruby 的expconf.rb 脚本假定OpenSSL 库将始终位于lib 目录中。解决这个单一的烦恼(并与 OpenSSL 冲突)是所有这一切中最困难的部分。 因此,要在/usr/local 中使用安装 OpenSSL,您必须做两件事:(1) 安装 Ruby --with-openssl-dir 开关,以及 (2) 重新编译 Ruby 的 OpenSSL 扩展,同时修改 Makefile 以指向 lib64 而不是 lib。因此,以 root 身份运行以下命令字符串:

    ruby-install ruby 1.9.3-p545 -- --with-openssl-dir=/usr/local
    cd /usr/local/src/ruby-1.9.3-p545/ext/openssl
    ruby extconf.rb
    

    编辑 openssl 的 Makefile 以替换如下内容:

      libpath = . $(libdir) /usr/local/lib
      LIBPATH =  -L. -L$(libdir) -Wl,-R$(libdir) -L/usr/local/lib -Wl,-R/usr/local/lib
    

    类似这样的:

      libpath = . $(libdir) /usr/local/lib64
      LIBPATH =  -L. -L$(libdir) -Wl,-R$(libdir) -L/usr/local/lib64 -Wl,-R/usr/local/lib64
    

    保存,返回命令行:

    make
    make install
    

    新的 Ruby 安装现在应该可以正常使用 OpenSSL。作为快速检查,我重新启动我的 sudo 会话,然后(假设使用 chruby):

    chruby 1.9
    ruby -ropenssl -e "puts OpenSSL::VERSION"
    

    规则 3

    /usr 之外的任何位置安装 OpenSSL 会将库放入预期的 lib 而不是 lib64。 (不要问我为什么……不知道。)这可能是更易于维护的解决方案,因为它可以让您避免破坏Makefile。这也是 RVM 在运行rvm pkg install openssl 时使用的解决方案。因此,要同时安装 OpenSSL 和 Ruby(在 /opt 中),您可以运行类似这样的命令(我以 sudo bash 运行):

    安装 OpenSSL:

    cd /opt/local
    wget http://www.openssl.org/source/openssl-1.0.1f.tar.gz
    tar -xzf openssl-1.0.1f.tar.gz
    cd openssl-1.0.1f
    ./config --prefix=/opt/local shared no-asm zlib > openssl_config.log
    make > openssl_make.log
    make install > openssl_install.log
    

    shared 开关是 Ruby 正确安装所必需的,no-asm 开关有助于消除 Make 警告但似乎不是必需的,zlib 和其他开关是可选的。)

    可选,更新 openssl 证书:

    cd /opt/local/ssl
    wget http://curl.haxx.se/ca/cacert.pem
    mv cacert.pem cert.pem
    cd /opt
    

    回到 Ruby:

    ruby-install ruby 1.9.3-p545 -- --with-openssl-dir=/opt/local
    

    新的 Ruby 安装现在应该可以正常使用 OpenSSL。作为快速检查,我重新启动我的 sudo 会话,然后(假设使用 chruby):

    chruby 1.9
    ruby -ropenssl -e "puts OpenSSL::VERSION"
    

    【讨论】:

      【解决方案2】:

      问题:

      此答案适用于 RVM。具体问题是在 CentOS 6 上安装 any 大于 2.2.1 的 ruby​​ 版本。运行 rvm install 2.2.2 将通过 rvm 构建 2.2.2 构建的构建 openssl 包装器版本失败。它会因多种原因而失败(未找到 lib、未找到符号等)

      解决方案:

      让 rvm 构建 openssl 包并使用它。这可能适用于其他红宝石:

      rvm pkg install openssl
      rvm remove 2.2.2
      rvm install 2.2.2 -C --with-openssl-dir=$HOME/.rvm/usr
      

      补充说明:

      如果您稍后由于 SSL 身份验证遇到错误(例如通过 gem 安装任何内容),则可能是由于在 .rvm/usr/ssl 目录中错误地提取了 CA 文件。只需将您的系统安装核心证书文件链接到cert.pem,ruby 应该能够完成身份验证。

      【讨论】:

        【解决方案3】:

        我想我找到了一个更简单的解决方案。

        显然,最近在 RedHat 和 Ruby 上对 OpenSSL 所做的更改存在一个已知问题:https://bugs.ruby-lang.org/issues/8384

        this patch 向后移植到您尝试安装的 1.9.3 版本应该可以解决问题。我在ruby-build FAQ 上找到了这个,这里有一些代码甚至可以应用补丁。

        【讨论】:

          猜你喜欢
          • 2012-08-09
          • 2015-11-13
          • 2023-04-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-09-17
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多