1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CentOS8 OpenSSL1.1.1をインストールする

Last updated at Posted at 2021-03-28

0. 前提

CentOS8でPython3.9と一緒にインストールしたpipコマンドを実行するにあたり、OpenSSL1.0.2以上のインストールが必要とのことだったので、OpenSSL1.1.1を入れた。

1. 依存関係のインストール

事前に以下インストールを実施すること。

コンパイルに必要

$ sudo yum install -y make gcc

opensslのビルドに必要

$ sudo yum install -y zlib-devel perl-core

2.ソースコードを取得

以下ページからソースコードを取得
https://www.openssl.org/source/
※今回はopenssl-1.1.1h.tar.gz

$ sudo curl https://www.openssl.org/source/openssl-1.1.1h.tar.gz -o /usr/local/src/openssl-1.1.1h.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9580k  100 9580k    0     0  6751k      0  0:00:01  0:00:01 --:--:-- 6746k

3.データの解凍

以下コマンドを実施しtar.gzファイルを解凍。

$ ls -ltr
合計 9584
-rw-r--r--. 1 root root 9810045 12月 5 11:15 openssl-1.1.1h.tar.gz
$ sudo tar xvzf openssl-1.1.1.tar.gz

4.opensslをソースからビルドしてインストール

以下コマンドでopensslをソースからビルドしてインストール

$ sudo ./config --prefix=/usr/local/openssl-1.1.1h shared zlib
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1h (0x1010108fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating 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 file first)         ***
***                                                                ***
**********************************************************************

続けて以下実行。

$ sudo make depend
$ sudo make
$ sudo make test
$ sudo make install

6.インストールされたことを確認

$ ls -l /usr/local/openssl-1.1.1h/
合計 0
drwxr-xr-x. 2 root root  37 12月 5 11:38 bin
drwxr-xr-x. 3 root root  21 12月 5 11:38 include
drwxr-xr-x. 4 root root 159 12月 5 11:38 lib
drwxr-xr-x. 4 root root  28 12月 5 11:40 share
drwxr-xr-x. 5 root root 140 12月 5 11:38 ssl

7.OpenSSLを共有ライブラリを追加する

ld.so.confを確認。ld.so.conf.d配下のファイルがincludeされていることを確認。

$ sudo cat /etc/ld.so.conf
include ld.so.conf.d/*.conf

openssl-1.1.1h.confを作成。

$ cat /etc/ld.so.conf.d/openssl-1.1.1h.conf
/usr/local/openssl-1.1.1h/lib/

キャッシュファイルを更新。

$ ldconfig
$ ldconfig -p | grep libssl
        libssl3.so (libc6,x86-64) => /lib64/libssl3.so
        libssl.so.1.1 (libc6,x86-64) => /usr/local/openssl-1.1.1h/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-1.1.1h/lib64/libssl.so

以下コマンドで動作確認をする。TLSv1.3に対応していることがわかる。

$ /usr/local/openssl-1.1.1h/bin/openssl ciphers -v | grep TLSv1.3
TLS_AES_256_GCM_SHA384  TLSv1.3 Kx=any      Au=any  Enc=AESGCM(256) Mac=AEAD
TLS_CHACHA20_POLY1305_SHA256 TLSv1.3 Kx=any      Au=any  Enc=CHACHA20/POLY1305(256) Mac=AEAD
TLS_AES_128_GCM_SHA256  TLSv1.3 Kx=any      Au=any  Enc=AESGCM(128) Mac=AEAD

Python に読み込ませたいとき

PythonにインストールしたOpensslを読み込ませる場合。
すでに実機にPython3.9がインストールされていたため、インストールに使ったファイルを削除

rm -rf /usr/local/python390

Pythonをインストール。

./configure --prefix=/usr/local/python390 --with-openssl=/usr/local/openssl-1.1.1h --with-ensurepip
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?