源码下载地址:
https://www.openssl.org/source/openssl-3.0.10.tar.gz
编写spec文件:
cat << 'EOF' > openssl.specSummary: OpenSSL 3.0.10 for CentosName: opensslVersion: %{?version}%{!?version:3.0.10}Release: 1%{?dist}Obsoletes: %{name} <= %{version}Provides: %{name} = %{version}URL: https://www.openssl.org/License: GPLv2+Source: https://www.openssl.org/source/%{name}-%{version}.tar.gzBuildRequires: make gcc perl perl-WWW-CurlBuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root%global openssldir /usr/openssl%descriptionOpenSSL RPM for version 3.0.10 on Centos%package develSummary: Development files for programs which will use the openssl libraryGroup: Development/LibrariesRequires: %{name} = %{version}-%{release}%description develOpenSSL RPM for version 3.0.10 on Centos (development package)%prep%setup -q%build./config --prefix=%{openssldir} --openssldir=%{openssldir}make%install[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}%make_installmkdir -p %{buildroot}%{_bindir}mkdir -p %{buildroot}%{_libdir}ln -sf %{openssldir}/lib/libssl.so.3 %{buildroot}%{_libdir}ln -sf %{openssldir}/lib/libcrypto.so.3 %{buildroot}%{_libdir}ln -sf %{openssldir}/bin/openssl %{buildroot}%{_bindir}%clean[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}%files%{openssldir}%defattr(-,root,root)/usr/bin/openssl/usr/lib64/libcrypto.so.3/usr/lib64/libssl.so.3%files devel%{openssldir}/include/*%defattr(-,root,root)%post -p /sbin/ldconfig%postun -p /sbin/ldconfigEOF
安装依赖包:
yum install curl which make gcc perl perl-WWW-Curl perl-CPAN perl-IPC-Cmd perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker -y
制作rpm包:
cd rpmbuild/SPEC/rpmbuild -ba openssl.spec
安装:
#卸载旧版openssl, 切记不要删除openssl-libsrpm -qa | grep openssl
rpm -e --justdb --nodeps <yourpackage>#安装新版
rpm -ivh openssl-xxx.rpm --nodeps#检查验证openssl versionrpm -qa | grep openssl# 找不到库文件,建立软链接解决ln -s /usr/openssl/lib64/libssl.so.3 /usr/lib64/libssl.so.3ln -s /usr/openssl/lib64/libcrypto.so.3 /usr/lib64/libcrypto.so.3