【OpenSSL】- Ubuntu22.04手动编译安装openssl

文章目录

下载代码

shell 复制代码
git clone https://github.com/openssl/openssl.git
git checkout -b openssl-3.5.4 #这里需要指定自己想要安装的版本

卸载Ubuntu自带的openssl

一定要先下载代码再卸载默认的openssl。否则git将无法进行安全验证导致下载代码失败。

查看默认的opessl版本

shell 复制代码
openssl version -a

ubuntu22.04默认安装的是3.0.2版本

卸载默认的openssl

shell 复制代码
sudo apt remove --purge openssl
sudo apt autoremove

编译openssl

https://github.com/openssl/openssl/blob/master/NOTES-UNIX.md

shell 复制代码
./Configure --prefix=/usr/lib/ssl/ --openssldir=/usr/lib/ssl/ '-Wl,-rpath,$(LIBRPATH)' #这里注意选择自己想要的安装目录
make -j8 #8为并行编译的线程数,由于我的虚拟机是8核心,因此启动8个线程编译
sudo make install #由于我指定的安装目录需要root权限,如果是普通目录可以省略sudo直接运行"make install"

验证安装

创建软连接

由于openssl默认安装路径为"/usr/lib/ssl/bin/openssl",因此需要在"/usr/bin"下建立一个软连接。否则直接执行"openssl",系统将找不到它。

shell 复制代码
sudo ln -s /usr/lib/ssl/bin/openssl /usr/bin/openssl

再执行openssl version -a查看结果,版本已经更新为3.5.4

恢复git功能

编译完openssl后,git clone代码会失败。

这是因为我们在卸载默认openssl时将ca-certificate一起卸载了。因此重新安装即可。

shell 复制代码
sudo apt install -y ca-certificates
sudo update-ca-certificates --fresh
相关推荐
Lsetea2 小时前
curl报91 No OCSP response received:cert-status与OCSP装订排查
https·ssl证书·openssl·curl·ocsp
Lsetea5 小时前
OpenSSL报self-signed certificate in certificate chain:error 19与信任根排查
https·ssl证书·openssl·curl·证书链
Lsetea1 天前
curl报58 unable to set private key file:客户端证书与私钥加载排查
运维·https·ssl证书·openssl·curl
Lsetea1 天前
OpenSSL报certificate is not yet valid:error 9与notBefore时间排查
linux·运维·https·ssl证书·openssl
Lsetea3 天前
curl用IP测试HTTPS报证书不匹配:--resolve与Host头别混用
linux·https·ssl证书·openssl·curl
Lsetea4 天前
OpenSSL verify报unable to get issuer certificate:error 2与partial_chain排查
linux·https·ssl证书·openssl·证书链
Lsetea5 天前
OpenSSL verify报unhandled critical extension:error 34与关键扩展排查
运维·https·ssl证书·openssl·证书链
Lsetea5 天前
OpenSSL verify报CA certificate key too weak:auth_level与弱密钥链排查
运维·https·ssl证书·openssl·证书链
Lsetea7 天前
OpenSSL verify报invalid CA certificate:basicConstraints与keyCertSign排查
运维·https·ssl证书·openssl·证书链
Lsetea9 天前
OpenSSL verify报error 62:证书主机名不匹配与-verify_hostname排查
运维·https·ssl证书·openssl·san