首先,要使用以下命令更新本地包索引:

sudo apt update

然后,使用以下命令安装 OpenSSL 3 的依赖项:

sudo apt install build-essential checkinstall zlib1g-dev -y

下载最新版的OpenSSL

此时,访问 GitHub OpenSSL Releases 页面或 **OpenSSL 官方下载**页面并使用 wget命令 下载最新版本

sudo wget https://github.com/openssl/openssl/releases/download/openssl-3.0.10/openssl-3.0.10.tar.gz
# sudo wget https://www.openssl.org/source/openssl-3.1.2.tar.gz
# sudo wget https://www.openssl.org/source/openssl-3.0.10.tar.gz

然后,使用以下命令解压下载的文件:

sudo tar -zxf openssl-3.0.10.tar.gz

接下来,进入到解压出来的 OpenSSL 目录:

cd openssl-3.0.10

在 Debian 11 上构建并安装 OpenSSL 3

使用以下命令来配置 OpenSSL:

./config --prefix=/usr/local/lib/openssl
Configuring OpenSSL version 3.1.2 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)      ***
***                                                                ***
**********************************************************************

接下来,使用以下命令构建 OpenSSL 3.0:

make
make test
make install

使用以下命令更新链接和缓存:

sudo ldconfig

然后,更新系统范围的 OpenSSL 配置:

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

重新加载shell环境:

source /etc/profile.d/openssl.sh

通过查看其版本来验证是否安装成功:

openssl version
OpenSSL 3.1.2 1 Aug 2023 (Library: OpenSSL 3.1.2 1 Aug 2023)

添加软链接:

sudo ln -s /usr/local/lib/openssl/lib64/libssl.so.3 /usr/lib/libssl.so.3
sudo ln -s /usr/local/lib/openssl/lib64/libcrypto.so.3 /usr/lib/libcrypto.so.3