본문 바로가기

리눅스

[리눅스] 우분투(Ubuntu 22.04 LTS)에 OpenSSL(openssl-1.1.1)설치하기

728x90

우분투(Ubuntu 22.04 LTS)에 OpenSSL(openssl-1.1.1)설치하기

테스트 환경

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04 LTS
Release:	22.04
Codename:	jammy


$ openssl version
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

컴파일에 필요한 패키지

apt install -y build-essential checkinstall zlib1g-dev

openssl 패키지 다운로드 및 체크섬 확인

OpenSSL : https://www.openssl.org/source/

curl -fsSL https://www.openssl.org/source/openssl-1.1.1n.tar.gz --output /usr/local/src/openssl-1.1.1n.tar.gz
curl -fsSL https://www.openssl.org/source/openssl-1.1.1n.tar.gz.sha256 --output /usr/local/src/openssl-1.1.1n.tar.gz.sha256
echo "$(cat openssl-1.1.1n.tar.gz.sha256) openssl-1.1.1n.tar.gz" | sha256sum --check
$ echo "$(cat openssl-1.1.1n.tar.gz.sha256) openssl-1.1.1n.tar.gz" | sha256sum --check
openssl-1.1.1n.tar.gz: OK

openssl 설치 및 설정

openssl 설치

tar xfz /usr/local/src/openssl-1.1.1n.tar.gz -C /usr/local/src/
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
make && make install
echo "/usr/local/ssl/lib" > /etc/ld.so.conf.d/openssl-1.1.1n.conf
ldconfig -v

environment 편집

- /usr/local/ssl/bin 추가

vim /etc/environment
$ vim /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/ssl/bin"
source /etc/environment; echo $PATH | grep '/usr/local/ssl/bin'
$ echo $PATH | grep '/usr/local/ssl/bin'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/ssl/bin

설치된 openssl 버전 확인

cd /usr/local/ssl/bin; ./openssl version
$ cd /usr/local/ssl/bin

$ ./openssl version
OpenSSL 1.1.1n  15 Mar 2022

심복릭 링크 설정

$ which openssl
/usr/local/ssl/bin/openssl
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

기존 openssl 제거

apt remove -y openssl
apt autoclean && apt autoremove

새로운 세션에서 설치된 openssl 현재 버전 확인

$ su -

$ openssl version
OpenSSL 1.1.1n  15 Mar 2022
728x90