はじめに
RHEL8系でOpenSSLの2019年9月時点の最新版1.1.1cを入れようとしたところ、エラーになりました。
インストールした手順と解決方法のメモ書きです。
環境
# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.0 (Ootpa)
# uname -a
Linux test 4.18.0-80.7.2.el8_0.x86_64 #1 SMP Wed Aug 7 20:30:34 GMT 2019 x86_64 x86_64 x86_64 GNU/Linux
事前の状態
# which openssl
/usr/bin/openssl
# opensl version -a
OpenSSL 1.1.1 FIPS 11 Sep 2018
built on: Sat May 25 15:29:07 2019 UTC
platform: linux-x86_64
options: bn(64,64) md2(char) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wa,--noexecstack -Wa,--generate-missing-build-notes=yes -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPADLOCK_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG -DPURIFY -DDEVRANDOM="\"/dev/urandom\"" -DSYSTEM_CIPHERS_FILE="/etc/crypto-policies/back-ends/openssl.config"
OPENSSLDIR: "/etc/pki/tls"
ENGINESDIR: "/usr/lib64/engines-1.1"
Seeding source: os-specific
engines: dynamic
インストール手順
OpenSSLをインストールしていきます。(NG手順から追っていきます)
# dnf install make gcc perl git expat-devel pcre-devel zlib-devel
# wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
# tar xf openssl-1.1.1c.tar.gz
# chown -R root. openssl-1.1.1c
# cd openssl-1.1.1c
# ./config --prefix=/usr/local/openssl-1.1.1c --openssldir=/usr/local/openssl-1.1.1c/shared zlib -fPIC
# make
# make install
# cd /usr/local
# ln -s openssl-1.1.1c openssl
(のちにapacheを入れる予定だったので関連するパッケージも入れています)
# /usr/local/openssl/bin/openssl version -a
OpenSSL 1.1.1c 28 May 2019 (Library: OpenSSL 1.1.1 FIPS 11 Sep 2018)
built on: Sat May 25 15:29:07 2019 UTC
platform: linux-x86_64
options: bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wa,--noexecstack -Wa,--generate-missing-build-notes=yes -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPADLOCK_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG -DPURIFY -DDEVRANDOM="\"/dev/urandom\"" -DSYSTEM_CIPHERS_FILE="/etc/crypto-policies/back-ends/openssl.config"
OPENSSLDIR: "/etc/pki/tls"
ENGINESDIR: "/usr/lib64/engines-1.1"
Seeding source: os-specific
ライブラリの状態
# ldconfig -p | grep libssl
libssl3.so (libc6,x86-64) => /lib64/libssl3.so
libssl.so.1.1 (libc6,x86-64) => /lib64/libssl.so.1.1
1.1.1cのライブラリを追加
# echo -e "/usr/local/openssl/lib" > /etc/ld.so.conf.d/openssl-1.1.1c.conf
# ldconfig
# ldconfig -p | grep libssl
libssl3.so (libc6,x86-64) => /lib64/libssl3.so
libssl.so.1.1 (libc6,x86-64) => /usr/local/openssl/lib64/libssl.so.1.1
libssl.so.1.1 (libc6,x86-64) => /lib64/libssl.so.1.1
libssl.so (libc6,x86-64) => /usr/local/openssl/lib64/libssl.so
opensslのパスを通す
echo -e 'OPENSSL_111C_PATH=/usr/local/openssl/bin\nPATH=$OPENSSL_111C_PATH:$PATH\nexport PATH' > /etc/profile.d/openssl-1.1.1c.sh
source /etc/profile.d/openssl-1.1.1c.sh
# type -ap openssl
/usr/local/openssl/bin/openssl
/usr/bin/openssl
# openssl version
OpenSSL 1.1.1c 28 May 2019
エラーの内容
/usr/bin/openssl
# /usr/bin/openssl version
/usr/bin/openssl: relocation error: /usr/bin/openssl: symbol EVP_md2 version OPENSSL_1_1_0 not defined in file libcrypto.so.1.1 with link time reference
# dnf --version
Traceback (most recent call last):
File "/usr/lib64/python3.6/site-packages/libdnf/conf.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /lib64/librpmio.so.8: symbol EVP_md2 version OPENSSL_1_1_0 not defined in file libcrypto.so.1.1 with link time reference
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/dnf", line 57, in <module>
from dnf.cli import main
File "/usr/lib/python3.6/site-packages/dnf/__init__.py", line 30, in <module>
import dnf.base
File "/usr/lib/python3.6/site-packages/dnf/base.py", line 29, in <module>
import libdnf.transaction
File "/usr/lib64/python3.6/site-packages/libdnf/__init__.py", line 3, in <module>
from . import conf
File "/usr/lib64/python3.6/site-packages/libdnf/conf.py", line 17, in <module>
_conf = swig_import_helper()
File "/usr/lib64/python3.6/site-packages/libdnf/conf.py", line 16, in swig_import_helper
return importlib.import_module('_conf')
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_conf'
/lib64/librpmio.so.8
がlibcrypto.so.1.1
に問題があると言っています。
libcrypto.so.1.1
は標準インストールされたものか、1.1.1cのどちらでしょうか。
# ldd /lib64/librpmio.so.8
linux-vdso.so.1 (0x00007fff0404f000)
libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f7935901000)
libz.so.1 => /lib64/libz.so.1 (0x00007f79356ea000)
libelf.so.1 => /lib64/libelf.so.1 (0x00007f79354d1000)
libpopt.so.0 => /lib64/libpopt.so.0 (0x00007f79352c4000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f793509d000)
liblua-5.3.so => /lib64/liblua-5.3.so (0x00007f7934e62000)
libm.so.6 => /lib64/libm.so.6 (0x00007f7934ae0000)
libcrypto.so.1.1 => /usr/local/openssl/lib64/libcrypto.so.1.1 (0x00007f79345ff000)
libaudit.so.1 => /lib64/libaudit.so.1 (0x00007f79343d5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f79341d1000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7933fb1000)
libc.so.6 => /lib64/libc.so.6 (0x00007f7933bed000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7935d44000)
libcap-ng.so.0 => /lib64/libcap-ng.so.0 (0x00007f79339e7000)
インストールしたOpenssl 1.1.1cを読んでいるようです。
EVP_md2
でググるとこんな記事が。
EVP_md2 symbol error(rougeref.hatenablog.com)
記事に従ってenable-md2
をつけてみます。
# ./config --prefix=/usr/local/openssl-1.1.1c --openssldir=/usr/local/openssl-1.1.1c/shared enable-md2 zlib -fPIC
(略)
# openssl version
openssl: relocation error: openssl: symbol BIO_new_dgram_sctp version OPENSSL_1_1_0 not defined in file libcrypto.so.1.1 with link time reference
エラーが変わりました。今度はBIO_new_dgram_sctp
が無いと出ます。
BIO_new_dgram_sctp enable config
あたりでググると、こんな記事がありました。
How to configure DTLS echo server and client code?(stackoverflow.com)
sctpをつけてみます。
# ./config --prefix=/usr/local/openssl-1.1.1c --openssldir=/usr/local/openssl-1.1.1c/shared enable-md2 sctp zlib -fPIC
(略)
makeエラーが出ました。
crypto/bio/bss_dgram.c:17:12: fatal error: netinet/sctp.h: No such file or directory
# include <netinet/sctp.h>
^~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:1576: crypto/bio/bss_dgram.o] Error 1
openssl netinet/sctp.h: No such file or directory
あたりでググります。
出ます。
netinet/sctp.h: No such file or directory(stackoverflow.com)
すごいぞstackoverflow。
# dnf install lksctp-tools lksctp-tools-devel
再度コンパイルします。
コンパイルは通りました。
インストールします。
# /usr/bin/openssl
/usr/bin/openssl: relocation error: /usr/bin/openssl: symbol RC5_32_set_key version OPENSSL_1_1_0 not defined in file libcrypto.so.1.1 with link time reference
また違うエラーがでました。
またenableにしなければならなかったり追加しなければならなったりするパターンでしょうか…
OpenSSLのオプションを見ます。
Compilation and Installation(wiki.openssl.org)
特にRC5_32_set_key
に関する記述はないようです。
enable-rc5を追加してみます。
# ./config --prefix=/usr/local/openssl-1.1.1c --openssldir=/usr/local/openssl-1.1.1c/shared enable-md2 enable-rc5 sctp zlib -fPIC
(略)
# /usr/bin/openssl version
OpenSSL 1.1.1 FIPS 11 Sep 2018 (Library: OpenSSL 1.1.1c 28 May 2019)
うまくいきました。
# /usr/bin/openssl version -a
OpenSSL 1.1.1 FIPS 11 Sep 2018 (Library: OpenSSL 1.1.1c 28 May 2019)
built on: Thu Sep 12 02:52:12 2019 UTC
platform: linux-x86_64
options: bn(64,64) md2(char) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -fPIC -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG
OPENSSLDIR: "/usr/local/openssl-1.1.1c/shared"
ENGINESDIR: "/usr/local/openssl-1.1.1c/lib/engines-1.1"
Seeding source: os-specific
engines: dynamic
# openssl version -a
OpenSSL 1.1.1c 28 May 2019
built on: Thu Sep 12 02:52:12 2019 UTC
platform: linux-x86_64
options: bn(64,64) md2(char) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -fPIC -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG
OPENSSLDIR: "/usr/local/openssl-1.1.1c/shared"
ENGINESDIR: "/usr/local/openssl-1.1.1c/lib/engines-1.1"
Seeding source: os-specific
dnfも動いています。
# dnf --version
4.0.9
インストール済み: dnf-0:4.0.9.2-5.el8.noarch (日時: 2019年09月11日 07時22分02秒)
ビルド : (日時: 2019年05月23日 16時24分40秒)
インストール済み: rpm-0:4.14.2-10.el8_0.x86_64 (日時: 2019年09月11日 08時10分26秒)
ビルド : (日時: 2019年07月30日 17時56分12秒)
おまけ
apacheのインストール
Openssl
dnf update
dnf install make gcc perl git expat-devel pcre-devel zlib-devel
wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
tar xf openssl-1.1.1c.tar.gz
chown -R root. openssl-1.1.1c
cd openssl-1.1.1c
./config --prefix=/usr/local/openssl-1.1.1c --openssldir=/usr/local/openssl-1.1.1c/shared enable-md2 enable-rc5 sctp zlib -fPIC
make && make install
cd /usr/local
ln -s openssl-1.1.1c openssl ;\
cd openssl ;\
echo -e "/usr/local/openssl/lib" > /etc/ld.so.conf.d/openssl-1.1.1c.conf ;\
ldconfig
echo -e 'OPENSSL_111C_PATH=/usr/local/openssl/bin\nPATH=$OPENSSL_111C_PATH:$PATH\nexport PATH' > /etc/profile.d/openssl-1.1.1c.sh
source /etc/profile.d/openssl-1.1.1c.sh
apr
cd /usr/local/src
wget https://www-us.apache.org/dist//apr/apr-1.7.0.tar.gz
tar xf apr-1.7.0.tar.gz
chown -R root. apr-1.7.0
cd apr-1.7.0
./configure --prefix=/usr/local/apr-1.7.0
make && make install
apr-util
cd /usr/local/src
wget https://www-us.apache.org/dist//apr/apr-util-1.6.1.tar.gz
tar xf apr-util-1.6.1.tar.gz
chown -R root. apr-util-1.6.1
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util-1.6.1 --with-apr=/usr/local/apr-1.7.0
make && make install
nghttp2
cd /usr/local/src
wget https://github.com/nghttp2/nghttp2/releases/download/v1.39.2/nghttp2-1.39.2.tar.gz
tar xf nghttp2-1.39.2.tar.gz
chown -R root. nghttp2-1.39.2
cd nghttp2-1.39.2
./configure --prefix=/usr/local/nghttp2-1.39.2
make && make install
apache
cd /usr/local/src
wget https://www-us.apache.org/dist//httpd/httpd-2.4.41.tar.gz
tar xf httpd-2.4.41.tar.gz
chown -R root. httpd-2.4.41
cd httpd-2.4.41
./configure --prefix=/usr/local/apache2.4.41 \
--enable-mods-shared=all \
--enable-ssl \
--enable-cache \
--enable-mem-cache \
--enable-deflate \
--enable-mime-magic \
--enable-mpms-shared=all \
--enable-usertrack \
--enable-so \
--enable-proxy \
--enable-http2 \
--enable-proxy-http2 \
--with-apr=/usr/local/apr-1.7.0 \
--with-apr-util=/usr/local/apr-util-1.6.1 \
--with-mpm=prefork \
--with-ssl=/usr/local/openssl \
--with-nghttp2=/usr/local/nghttp2-1.39.2
make && make instal
起動スクリプト。
# vim /usr/lib/systemd/system/apache2.4.41.service
[Unit]
Description=The Apache 2.4.41 HTTP Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=notify
ExecStart=/usr/local/apache2.4.41/bin/httpd -DFOREGROUND
ExecReload=/usr/local/apache2.4.41/bin/httpd -k graceful
ExecStop=/usr/local/apache2.4.41/bin/apachectl stop
KillSignal=SIGCONT
PrivateTmp=true
PIDFile=/usr/local/apache2.4.41/logs/httpd.pid
# systemctl daemon-reload
mod_systemdの追加
cd /usr/local/src
dnf install --downloadonly --downloaddir=/tmp httpd
mkdir mod_systemd
cd mod_systemd
rpm2cpio /tmp/httpd-2.4.*x86_64.rpm | cpio -id ./usr/lib64/httpd/modules/mod_systemd.so
cp ./usr/lib64/httpd/modules/mod_systemd.so /usr/local/apache2.4.41/modules/
mod_systemd.soをロードさせる
vim /usr/local/apache2.4.41/conf/httpd.conf
LoadModule systemd_module modules/mod_systemd.so
# /usr/local/apache2.4.41/bin/apachectl -t
Syntax OK
# systemctl start apache2.4.41
# curl localhost
<html><body><h1>It works!</h1></body></html>
おしまいです。