Проблема с OpenSSL на RHEL 6.3 и всеми установщиками Ruby
Похоже, что OpenSSL компилируется неправильно при установке любой версии Ruby в нашей системе RHEL 6.3. Я пытался оставить пользовательские установки RVM и заменить их установками root через ruby-install и chruby. OpenSSL работает нормально в наших пользовательских установках RVM (с предписанным исправлением RVM), а также при установке встроенной системы Ruby 1.8.7 в /usr/bin
,
OpenSSL is broken in each Ruby version I have tried with ruby-install, ruby-build, and even RVM when using their latest suggested fix. 1.9.3-p392 (our prod version), 1.9 latest, and 2.1.0 current. I have tried every openssl fix/workaround I can find, such as the --with-openssl-dir=/some/dir
config pointing to various openssl folders, but nothing works for me.
Here are some relevant messages from a few of my many attempts:
[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
Note all the ossl warnings above.
Restart session. Test system Ruby 1.8.7 openssl: Works. Test ruby-install Ruby 1.9.3 openssl: Fails.
[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
Test RVM Ruby 1.9.3 openssl in user home: Works.
[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
3 ответа
После долгих часов исследований и изучения гораздо большего, чем я когда-либо думал о Linux, я сузил проблему до базовых особенностей RHEL и OpenSSL и неверного предположения, сделанного Ruby (extconf.rb) во время установки. Следующие сайты дали мне несколько хороших подсказок относительно того, на что смотреть, но я не нашел ничего, что могло бы соединить все вместе так, как мне было нужно.
- http://www.openssl.org/support/faq.html
- http://wiki.openssl.org/index.php/Compilation_and_Installation
- http://sachachua.com/blog/2011/04/setting-up-ruby-on-rails-on-a-redhat-enterprise-linux-rackspace-cloud-server/
- https://web.archive.org/web/20130430124941/https://rvm.io/packages/openssl/
... и не очень, благодаря целой куче красных селедок, включающих в себя заплатки Ruby и EC2M. Кроме того, RVM необходимо исправить свой оптимизм в отношении того, что они объяснили это с помощью autolibs, и восстановить прежнюю страницу openssl.
Основные правила решения
Правило 1
Установка OpenSSL (1.0.1e), созданная и поддерживаемая yum в /usr/bin
не может быть использован для правильной компиляции расширения OpenSSL в Ruby - по крайней мере, не на моем компьютере с последними версиями Ruby (1.9.3-p484, 2.0.0, 2.1.0). РЕЛ 6.3. Я могу только предположить, что это связано с особенностями компиляции OpenSSL в RedHat, на что намекают в FAQ по OpenSSL.
Правило 2
Я нашел две старые версии (0.9.8) OpenSSL в /usr/local
(в bin
+ openssl
, а также ssl/bin
) и их обновление / замена немного приблизили меня к решению. По любой причине каждая ручная установка OpenSSL 1.0.1f в /usr/local
(независимо от расположения директории bin,openssl,ssl) настаивал на /usr/local/lib64
вместо /usr/local/lib
(если я не взломал Makefile
, конечно). Руби expconf.rb
сценарий, однако, предполагает, что библиотеки OpenSSL всегда будут в lib
каталог. Погоня за этим единственным раздражением (и столкновение с OpenSSL) была самой сложной частью всего этого. Поэтому, чтобы сделать использование установки OpenSSL в /usr/local
работать, вы должны сделать две вещи: (1) установить Ruby с --with-openssl-dir
и (2) перекомпилируйте расширение OpenSSL в Ruby, одновременно изменяя 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
Отредактируйте Makefile openssl, чтобы заменить что-то вроде этого:
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
Установка OpenSSL в любом месте, кроме /usr
помещает библиотеки в ожидаемый 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
(The shared
для установки без ошибок требуется переключатель, 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"
Проблема:
Этот ответ относится к RVM. Конкретная проблема заключается в установке любой версии ruby больше, чем 2.2.1 на CentOS 6. Запуск rvm install 2.2.2
потерпит неудачу с версией оболочки openssl сборки 2.2.2 через rvm. Это не удастся по нескольким причинам (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), это может быть связано с неправильно извлеченным CA-файлом в .rvm/usr/ssl
каталог. Просто свяжите файл основных сертификатов вашей системы с cert.pem
и ruby должен иметь возможность завершить аутентификацию.
Я думаю, что нашел более простое решение.
По-видимому, существует известная проблема с недавними изменениями в OpenSSL для RedHat и Ruby: https://bugs.ruby-lang.org/issues/8384
Возвращение этого патча к версии 1.9.3, которую вы пытаетесь установить, должно помочь. Я нашел это в FAQ по сборке ruby, и вот некоторый код, чтобы даже применить патч.