OpenSSL をビルドしてみたので、記録として残す。
ビルド環境は Red Hat Enterprise Linux 7.9 です。
ソースコードをダウンロード
OpenSSLのサイトからソース一式をダウンロードします。
Downloads
タブをクリックすると、各バージョンの tar.gz がダウンロードできます。
今回はopenssl-3.0.14.tar.gz
をダウンロードしました。
wget https://www.openssl.org/source/openssl-3.0.14.tar.gz
ダウンロードしたら任意の場所に展開します。
tar zxvf openssl-3.0.14.tar.gz
ビルドの準備
ソースを展開すると、ビルド方法がINSTALL.md
に記載されています。
やることを抜粋すると以下です。
Building OpenSSL
----------------
Use the following commands to configure, build and test OpenSSL.
The testing is optional, but recommended if you intend to install
OpenSSL for production use.
### Unix / Linux / macOS / NonStop
$ ./Configure
$ make
$ make test
で、私の環境ではビルドに必要なパッケージが存在しなくてエラーが出ました。
以下にそれを記載しておきますが、当環境はもともと yum groupinstall で開発ツール (development)
等をインストール済みです。
./Configure 実行時に不足していたパッケージ
Can't locate IPC/Cmd.pm in @INC
で始まるエラーが出ました。
必要なパッケージは以下でした。
yum install perl-IPC-Cmd
make test 実行時に不足していたパッケージ
Can't locate Test/More.pm in @INC
で始まるエラーが出ました。
必要なパッケージは以下でした。
yum install perl-Test-Simple
ビルドの実行
実際のビルドの様子です。
./Configure の実行
こんな感じでした。
# ./Configure
Configuring OpenSSL version 3.3.1 for target linux-x86_64
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created Makefile.in
Created Makefile
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL.md file first) ***
*** ***
**********************************************************************
make の実行
こんな感じでした。
/usr/bin/perl "-I." "-Mconfigdata" "-Mbuilddata" "util/dofile.pl" "-oMakefile" exporters/cmake/OpenSSLConfig.cmake.in > OpenSSLConfig.cmake
/usr/bin/perl "-I." "-Mconfigdata" "-Mconfigdata" "-Mbuilddata" "util/dofile.pl" "-oMakefile" exporters/cmake/OpenSSLConfigVersion.cmake.in > OpenSSLConfigVersion.cmake
/usr/bin/perl "-I." "-Iutil/perl" "-Mconfigdata" "-MOpenSSL::paramnames" "util/dofile.pl" "-oMakefile" crypto/params_idx.c.in > crypto/params_idx.c
・・・
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" util/wrap.pl.in > "util/wrap.pl"
chmod a+x util/wrap.pl
make[1]: Leaving directory `/home/unix/openssl-3.3.1'
成功したのかどうかが分からなかったのですが、終了コードecho $?
が 0 だったので成功したのでしょう。
実行が終了するとカレントディレクトリ
に共有ライブラリ
やシンボリックリンク
が作成されていました。
-rwxr-xr-x 1 root root 5578616 6月 8 17:00 libcrypto.so.3
lrwxrwxrwx 1 root root 14 6月 8 17:00 libcrypto.so -> libcrypto.so.3
-rwxr-xr-x 1 root root 1195536 6月 8 17:00 libssl.so.3
lrwxrwxrwx 1 root root 11 6月 8 17:00 libssl.so -> libssl.so.3
make test の実行
こんな感じでした。
いくつかのテストがSkipされていましたがResult: PASS
と表示されたので成功したようです。
# make test
Result: NOTESTS
01-test_abort.t ......................... ok
01-test_fipsmodule_cnf.t ................ skipped: Test only supported in a fips build
01-test_sanity.t ........................ ok
01-test_symbol_presence.t ............... ok
・・・
99-test_fuzz_v3name.t ................... ok
99-test_fuzz_x509.t ..................... ok
All tests successful.
Files=312, Tests=3675, 240 wallclock secs ( 4.33 usr 0.25 sys + 159.85 cusr 42.86 csys = 207.29 CPU)
Result: PASS
良かった良かった。
以上です。