openssl升级

  • CentOS 系统中从 OpenSSL 1.0.2k-fips 升级到 OpenSSL 1.1.1w(源码编译安装)

  • 升级 OpenSSL 可能影响依赖它的服务(如 Nginx、Apache、Postfix 等),建议在测试环境验证后再应用于生产环境,并提前做好系统快照或备份。

OpenSSL 是 Linux 系统中用于实现 SSL/TLS 加密通信的核心库,广泛应用于 Web 服务器、数据库、邮件系统等关键服务。随着时间推移,旧版本的 OpenSSL 会暴露出越来越多的安全漏洞。例如,OpenSSL 1.0.2k-fips 虽然带有 FIPS 认证,但已停止维护,存在潜在安全风险。

一、检查当前 OpenSSL 版本

复制代码
openssl version
    OpenSSL 1.0.2k-fips  26 Jan 2017
​

二、安装依赖

复制代码
yum install perl gcc zlib-devel

三、下载 OpenSSL 1.1.1

下载链接 https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz

复制代码
yum install perl gcc zlib-devel
cd /usr/local/src
wget -c https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz

四、开始安装

复制代码
tar xvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
# 配置时指定安装路径,避免覆盖系统默认版本。
./config --prefix=/usr/local/openssl111
# 编译安装
make -j4 && make install
​
​

五、设置PATH

复制代码
# 将新版本 bin 目录加入 PATH 开头
echo 'export PATH="/usr/local/openssl111/bin:$PATH"' >>  /etc/profile.d/openssl.sh
. /etc/profile.d/openssl.sh
​
# 更新动态链接库缓存
echo "/usr/local/openssl111/lib" >> /etc/ld.so.conf.d/openssl-1.1.1w.conf
## 刷新动态库缓存
ldconfig -v
​
​

六、升级验证

复制代码
openssl version 
    OpenSSL 1.1.1w  11 Sep 2023
​

附:openssl自签证书

复制代码
mkdir  ~/CA-SSL && cd ~/CA-SSL
#回到root用户的家目录下
#使用ssl生成私钥名为 yangge-tech.com.key;私钥密码 Ouyang666
openssl genrsa -des3 -out yangge-tech.com.key 1024
#基于创建的yangge-tech.com.key私钥创建yangge-tech.com.csr公钥
openssl req -new -key yangge-tech.com.key -out yangge-tech.com.csr
​
    ...
    Country Name (2 letter code) [XX]:CN
    State or Province Name (full name) []:BJ
    Locality Name (eg, city) [Default City]:BJ
    Organization Name (eg, company) [Default Company Ltd]:ZHY
    Organizational Unit Name (eg, section) []:ZHY
    Common Name (eg, your name or your server's hostname) []:yangge-tech.com
    Email Address []:fengyang@yangge-tech.com
​
    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:Ouyang666
    An optional company name []:ZHY  
​
#查看私钥加密的内容
openssl req -text -in yangge-tech.com.csr -noout
​
#基于yangge-tech.com.key私钥生成yangge-tech.com.key.unsecure的解密私钥
openssl rsa -in yangge-tech.com.key -out yangge-tech.com.key.unsecure
​
​
签名方法1:方法1需要输入密码,私钥密码为 Ouyang666
openssl  x509 -req -days 3650 -in yangge-tech.com.csr -signkey yangge-tech.com.key -out yangge-tech.com.crt
#使用私钥和公钥生成yangge-tech.com.crt签名证书,-days为3650天 -in指定公钥,-signkey指定私钥,生成的前面证书为yangge-tech.com.crt
签名方法2:
openssl x509 -req -days 3650 -in yangge-tech.com.csr -signkey yangge-tech.com.key.unsecure -out yangge-tech.com.crt
#使用解密私钥和公钥生成yangge-tech.com.crt签名证书,-days为3650天 -in指定公钥,-signkey指定解密后的私钥,生成的前面证书为yangge-tech.com.crt
​
#查看证书的内容,yangge-tech.com.crt内容
openssl -text -in yangge-tech.com.crt -noout
​
###apache配置
第一:
​
在httpd.conf中找到下面两行去掉前面的注释 # 
​
 LoadModule ssl_modulemodules/mod_ssl.so 
 Include conf/extra/httpd-ssl.conf 
​
第二:
​
在httpd-ssl.conf中:mkdir zhy
​
ssl_certificate "$path/yangge-tech.com.crt";
ssl_certificate_key "$path/yangge-tech.com.key.unsecure";
​
相关推荐
Lsetea6 小时前
OpenSSL verify报error 62:证书主机名不匹配与-verify_hostname排查
运维·https·ssl证书·openssl·san
Lsetea11 小时前
OpenSSL verify报certificate signature failure:error 7与证书签名排查
运维·https·ssl证书·openssl·证书链
Lsetea2 天前
curl指定CA目录仍报证书不受信任:--capath与OpenSSL rehash排查
运维·https·ssl·openssl·curl
Lsetea2 天前
OpenSSL报path length constraint exceeded:CA层级与pathlen排查
运维·https·ssl证书·openssl·证书链
Lsetea2 天前
OpenSSL s_client退出码为0却证书验证失败:严格校验与Shell管道排查
https·shell·ssl证书·openssl·tls
Lsetea2 天前
OpenSSL报permitted subtree violation:证书SAN与CA名称约束排查
运维·https·ssl证书·openssl·证书链
Lsetea4 天前
OpenSSL verify报error 20:CAfile、fullchain与本地信任链分层排查
nginx·https·ssl证书·openssl·证书链
Lsetea11 天前
证书没到期却报certificate has expired:OpenSSL定位中间证书与系统时间
运维·https·ssl证书·openssl·证书链
Lsetea12 天前
Nginx报No required SSL certificate was sent:mTLS客户端证书排查
运维·nginx·https·ssl·openssl
Lsetea13 天前
部署证书后提示“证书名称与输入不匹配”:Safari 报错的三层排查
nginx·https·safari·ssl证书·openssl