在 CentOS 7 / RHEL 7 上安装 OpenSSL 1.1.x

OpenSSL 是一个开源软件库,由用于实现传输层安全 (TLS) 和安全套接字层 (SSL) 协议以及其他加密功能(例如签名、加密、解密和验证)的工具和库组成。操作系统和许多应用程序使用 OpenSSL 通过互联网提供安全通信。

CentOS 7 / RHEL 7 操作系统上可用的 OpenSSL 版本有点旧,如果需要较新的版本,某些应用程序在编译时会出现错误。

Plaintext 复制代码
$ sudo yum -y install openssl openssl-devel
$ openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

从输出中可以看出,可用版本是1.0.2。如果已安装,请在继续之前将其删除。

Plaintext 复制代码
sudo yum -y remove openssl openssl-devel

确认已卸载。

Plaintext 复制代码
$ openssl version
-bash: openssl: command not found

在 CentOS 7 / RHEL 7 上安装 OpenSSL 1.1.x

OpenSSL 库提供了一套全面的加密功能,包括数字签名、对称和非对称加密、散列和证书管理。它还支持多种加密算法,包括 RSA、DSA、Diffie-Hellman 和椭圆曲线加密。

安装构建 OpenSSL 所需的依赖项。

Plaintext 复制代码
sudo yum -y groupinstall "Development Tools"

下载OpenSSL 1.1.x的源代码,其中x替换为实际需要的版本。

Plaintext 复制代码
wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz

提取下载的文件。

Plaintext 复制代码
tar xvf openssl-1.1.1t.tar.gz

导航到从文件提取创建的目录。

Plaintext 复制代码
cd openssl-1.1*/

配置 OpenSSL。您可以指定

Plaintext 复制代码
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl

在哪里:

  • --prefix 并 --openssldir 控制已安装组件的配置。
Plaintext 复制代码
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1t (0x1010114fL) 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)         *
*                                                                *
**********

使用make命令构建 OpenSSL 1.1.x。

Plaintext 复制代码
make -j $(nproc)

在 CentOS 7 / RHEL 7 上安装 OpenSSL 1.1.1

Plaintext 复制代码
sudo make install

更新共享库缓存。

Plaintext 复制代码
sudo ldconfig

更新系统范围的 OpenSSL 配置:

Plaintext 复制代码
sudo tee /etc/profile.d/openssl.sh<<EOF
export PATH=/usr/local/openssl/bin:\$PATH
export LD_LIBRARY_PATH=/usr/local/openssl/lib:\$LD_LIBRARY_PATH
EOF

重新加载shell环境:

Plaintext 复制代码
source /etc/profile.d/openssl.sh

注销当前的 shell 会话:

Plaintext 复制代码
logout

重新登录并验证 CentOS 7 / RHEL 7 上是否安装了 OpenSSL 1.1.1

Plaintext 复制代码
$ which openssl
/usr/local/openssl/bin/openssl
$ openssl version
OpenSSL 1.1.1t  7 Feb 2023

结论

OpenSSL 得到广泛使用,多年来一直受到信任,但它也成为多个备受瞩目的安全漏洞和攻击的目标。因此,保持 OpenSSL 最新并遵循安全使用的最佳实践非常重要。在本文中,我们演示了如何在 CentOS 7 / RHEL 7 系统上安装 OpenSSL 1.1.x。这是操作系统基础存储库中分发的默认版本的更新。

相关推荐
未济3 天前
linux 配置环境变量
linux
傲世仙尊3 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
虎头金猫3 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
_艾伦 耶格尔.3 天前
进程间通信
linux
AI职业加油站3 天前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
Liuqy-053 天前
Linux IO编程——静态库、动态库
linux
此冬歌咏3 天前
K8s 节点故障实战:优雅驱逐 31 秒,硬故障 331 秒,以及那个永远 Pending 的 Pod
运维·k8s
彧azz3 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅3 天前
linux(8) 软硬链接
linux·运维·服务器
AIgorithmGEEK3 天前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid