cenots7升级openssl到 3.x

原文地址:https://www.jianshu.com/p/e83595604846

升级步骤:

Openssl官网:https://www.openssl.org/source/

#查看SSL版本
[root@cnki-120-145-80 ~]# openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

#获取旧的openssl命令的位置
[root@cnki-120-145-80 ~]# which openssl
/usr/bin/openssl
[root@cnki-120-145-80 ~]# whereis openssl
openssl: /usr/bin/openssl /usr/lib64/openssl /usr/include/openssl /usr/share/man/man1/openssl.1ssl.gz


#================ 升级SSL ==============
#1.进入opt 目录
cd /opt

#2.下载Openssl
wget https://www.openssl.org/source/openssl-3.0.4.tar.gz

#3.解压
tar -xvf openssl-3.0.4.tar.gz

#4.进入解压后的目录
cd openssl-3.0.4

#5.编译(这一步可能会报错,请看报错1、报错2、报错3)
#./config --prefix=/usr/local/openssl shared zlib

./config --prefix=/usr/local/openssl shared 
#make depend

#6.这一步可能会报错,请看报错2
#make & make install
make
#make test 
sudo make install


#7.备份之前的ssl
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak

#8.将默认的openssl命令指向新的
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl

#9.更新动态链接库数据
echo "/usr/local/openssl/lib64" >> /etc/ld.so.conf

#10.加载配置
ldconfig -v


#11.查看是否升级成功
[root@cnki-120-145-80 openssl-3.0.4]# openssl version
OpenSSL 3.0.4 21 Jun 2022 (Library: OpenSSL 3.0.4 21 Jun 2022)

报错1:

#错误
Can't locate IPC/Cmd.pm in @INC (@INC contains: /opt/openssl-3.0.4/util/perl /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /opt/openssl-3.0.4/external/perl/Text-Template-1.56/lib) at /opt/openssl-3.0.4/util/perl/OpenSSL/config.pm line 18.
BEGIN failed--compilation aborted at /opt/openssl-3.0.4/util/perl/OpenSSL/config.pm line 18.
Compilation failed in require at /opt/openssl-3.0.4/Configure line 24.
BEGIN failed--compilation aborted at /opt/openssl-3.0.4/Configure line 24.



#安装perl-CPAN
yum install -y perl-CPAN

#全部默认(回车)
perl -MCPAN -e sh

#在shell中安装缺少的模块
cpan[1]> install IPC/Cmd.pm

#安装完成退出 Ctrl+Z

报错2:

#错误1
Failure!  build file wasn't produced.
Please read INSTALL.md and associated NOTES-* files.  You may also have to
look over your available compiler tool chain or change your configuration.

ERROR!
No C compiler found, please specify one with the environment variable CC,
or configure with an explicit configuration target.

#错误2
ib-c_zlib.d.tmp -MT crypto/comp/libcrypto-lib-c_zlib.o -c -o crypto/comp/libcrypto-lib-c_zlib.o crypto/comp/c_zlib.c
crypto/comp/c_zlib.c:36:19: fatal error: zlib.h: No such file or directory
 # include <zlib.h>
                   ^
compilation terminated.
make[1]: *** [crypto/comp/libcrypto-lib-c_zlib.o] Error 1
make[1]: Leaving directory `/opt/openssl-3.0.4'
make: *** [build_sw] Error 2

#解决
yum install  -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel  pam-devel

  

报错3:

错误:
To build 64-bit package, do this: /opt/openssl-3.0.4/Configure linux64-mips6

解决
./Configure linux64-mips64  --prefix=/usr/local/openssl shared 

  

posted @ 2024-03-24 16:17  天涯已可  阅读(306)  评论(0编辑  收藏  举报