雷达智富

首页 > 内容 > 程序笔记 > 正文

程序笔记

在 Rocky/Alma/CentOS/RHEL 8 上安装 OpenSSL 3.x

2024-07-07 70

在当前不断发展的网络安全格局中,保持领先于潜在的安全威胁至关重要。 OpenSSL 是著名的开源工具包,在保护网络计算机系统之间的通信安全方面发挥着关键作用。它提供了传输层安全 (TLS) 和安全套接字层 (SSL) 协议的开放实现,可保证网络中或通过互联网的设备之间传输的数据的完整性、真实性和机密性。

在撰写本文时,OpenSSL 3.1 是 OpenSSL 的最新版本。它具有大量改进和新功能,使其在保护数字通信和应对新兴威胁方面更加有效。在接下来的部分中,我们将介绍在 Rocky/Alma/CentOS/RHEL 8 上安装 OpenSSL 3.x 所需的步骤。

在 Rocky/AlmaLinux/CentOS/RHEL 8 上安装 OpenSSL 3.x

以下是在基于 CentOS/RHEL 的 Linux 发行版上安装 OpenSSL 3.x 时需要遵循的步骤。

第1步:更新系统

运行这些命令以确保基于 RHEL 的系统具有最新的安全补丁和软件更新。

sudo dnf -y update

应用更新后,您可以重新启动系统以使用最新的软件更新。

sudo reboot

步骤 2:卸载 OpenSSL 1.1

如果运行以下命令,它将显示当前安装的 OpenSSL 版本:

$ openssl version
OpenSSL 1.1.1k  FIPS 25 Mar 2021

我们将卸载这个旧版本,然后在系统上安装 OpenSSL 3.x。

sudo dnf remove openssl

查看依赖于此 OpenSSL 版本且可能被删除的其他应用程序。确认卸载。

$ openssl version
-bash: /usr/bin/openssl: No such file or directory

第三步:安装依赖包

OpenSSL 可能依赖于一些关键包来运行。安装基本的开发依赖项:

sudo dnf -y groupinstall "Development Tools"
sudo dnf -y install perl-IPC-Cmd  perl-Pod-Html

现在应该安装 Make 和 Gcc 软件包。

$  gcc --version
gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make --version
GNU Make 4.2.1
Built for x86_64-redhat-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

步骤 4:下载并安装 OpenSSL 3.x

从 OpenSSL 下载页面下载 OpenSSL 3 版本。请记住将 URL 替换为从链接中获取的 URL。

# Version 3.1.x
cd /tmp
wget https://www.openssl.org/source/openssl-3.1.3.tar.gz

# Version 3.0.x
cd /tmp
wget https://www.openssl.org/source/openssl-3.0.11.tar.gz

解压缩下载的压缩存档文件。

tar xvf openssl-*.tar.gz

文件提取后导航到创建的文件夹。

cd openssl-*/

配置用于安装 OpenSSL 3.x 的文件

./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl

在哪里 :

  • --prefix--openssldir 控制已安装组件的配置。

这是来自执行的消息。

Configuring OpenSSL version 3.1.3 for target linux-x86_64
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created Makefile.in
Created Makefile
Created include/openssl/configuration.h

**********************************************************************
***                                                                ***
***   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)      ***
***                                                                ***
**********************************************************************

构建并编译 OpenSSL 3.x 软件。

make -j $(nproc)

上面的命令将生成可执行文件和库,可以将它们复制到 Linux 系统上的适当位置。

sudo make install

使用以下命令配置和更新动态链接器运行时绑定。

sudo ldconfig

最后,我们可以更新 PATH 环境变量,该变量指定系统中可执行二进制文件所在的所有目录。

sudo tee /etc/profile.d/openssl.sh<<EOF
export PATH=/usr/local/openssl/bin:\$PATH
export LD_LIBRARY_PATH=/usr/local/openssl/lib:/usr/local/openssl/lib64:\$LD_LIBRARY_PATH
EOF

我们还使用 LD_LIBRARY_PATH 配置动态库路径以包含 OpenSSL 目录。完成后更新环境变量:

source /etc/profile.d/openssl.sh

确认安装的 OpenSSL 版本。

$ openssl version
OpenSSL 3.1.3 19 Sep 2023 (Library: OpenSSL 3.1.3 19 Sep 2023)

我们可以测试依赖 OpenSSL 的软件包的安装。

sudo dnf install policycoreutils-python-utils

结论

采用 OpenSSL 3.x 意味着您关心安全性。这样您就可以享受数字基础设施的持续弹性。 OpenSSL 是数字互连世界中无可争议的盟友。 OpenSSL 开发社区致力于推动网络安全领域的前沿发展。我们希望这篇文章对您有所帮助。


更新于:2个月前
赞一波!

文章评论

全部评论(2)