CRL has expired(OpenSSL: error:140890B2:SSL routines:SSL3_GET_CLIENT_CERTIFICATE)

博客讲述了服务器突然出现所有客户端无法连接的问题,经过日志分析发现是CRL(证书撤销列表)过期导致的TLS握手失败。作者通过检查和更新CRL解决了问题,并调整了CRL的更新周期以防止类似问题再次发生。

程序一直使用都很正常,突然有一天所有客户端都无法连接,查看服务器日志后发现出现如下错误:

TLS: Initial packet from [AF_INET]19.10.5.11:51849, sid=ba13f8a4 4c4aec28
VERIFY ERROR: depth=0, error=CRL has expired: CN=client1
OpenSSL: error:140890B2:SSL routines:SSL3_GET_CLIENT_CERTIFICATE:no certificate returned
TLS_ERROR: BIO read tls_read_plaintext error
TLS Error: TLS object -> incoming plaintext read error
TLS Error: TLS handshake failed
SIGUSR1[soft,tls-error] received, client-instance restarting

回想这段时间也没有对服务器端做过什么修改,只是大概一个月前吊销了一些不需要的证书,故使用如下命令查询一下CRL有效期,发现果然是CRL文件过期了

openssl crl -inform PEM -in keys/crl.pem -text -noout

一般情况下可以使用以下命令更新CRL列表,然后再将新的CRL列表复制到程序的目录既可

openssl ca -gencrl -keyfile keys/ca.key -cert keys/ca.crt -out keys/crl.pem -config openssl-1.0.0.cnf

默认情况下,CRL每30天更新一次。这在[CA_default]部分的配置如下所示:

default_crl_days= 30

为了避免相应的问题再次出现将其改为3650: 

default_crl_days = 3650

改完配置后再用上面的命令重新生成CRL列表后覆盖程序目录下的文件再重启程序,客户端又可以正常连接了,至此问题解决。

<think> Hmm, the user is asking about solving an &#39;upstream connect error&#39; specifically caused by &#39;SSLV3_ALERT_CERTIFICATE_EXPIRED&#39;. Let me analyze this carefully. First, looking at the error message: "TLS error: 268436501:SSL routines:OPENSSL_internal:SSLV3_ALERT_CERTIFICATE_EXPIRED". This clearly indicates that the SSL certificate has expired. The user likely encountered this while connecting to an upstream server through Nginx or similar proxy. The references provided give useful context. Reference [1] mentions CA certificates for SSL verification, reference [2] shows Nginx SSL configuration, and reference [3] discusses TCP socket connections. These all relate to SSL/TLS setup. The core issue here is certificate expiration. When a certificate expires, any SSL handshake will fail with this specific alert. The solution path should be: - Verify certificate expiration dates - Renew expired certificates - Update configurations with new certificates - Ensure proper certificate chain I notice the user is probably configuring Nginx based on reference [2]&#39;s example. The error likely occurs between Nginx and upstream servers. I should emphasize checking both the client-side (Nginx) certificate and the upstream server&#39;s certificate. For the solution steps, I&#39;ll need to cover: 1. How to check certificate expiration (using OpenSSL commands) 2. Renewal process (depends on CA) 3. Updating Nginx configuration (as shown in reference [2]) 4. Reloading services 5. Additional checks like time synchronization The user seems technical, working with Nginx and upstream services. The query is precise, showing they understand the error meaning but need implementation guidance. I should provide clear command examples and configuration snippets. Since certificate issues can cause serious downtime, I&#39;ll stress urgency in renewal while also mentioning prevention through monitoring and auto-renewal setups. The response should balance immediate fixes with long-term maintenance. </think> 根据您遇到的 `upstream connect error` 和 `SSLV3_ALERT_CERTIFICATE_EXPIRED` 错误,结合引用内容,解决方法如下: ### 根本原因分析 该错误表明 SSL 证书**已过期**或**配置错误**,导致 Nginx 与上游服务器建立 TLS 连接失败。核心问题在于: 1. 上游服务器SSL 证书已过期(最常见) 2. Nginx 配置中证书路径错误或权限问题 3. 系统时间不同步导致证书验证失败 ### 解决步骤 1. **检查证书有效期** 在 Nginx 服务器执行: ```bash openssl x509 -noout -dates -in /etc/nginx/ssl/your_domain.crt ``` 查看 `notAfter` 日期是否过期。 2. **更新过期证书** 若证书过期: - 联系证书颁发机构(CA)重新签发 - 使用 Let&#39;s Encrypt 免费续签: ```bash certbot renew --force-renewal ``` 3. **核对 Nginx 配置** 确保配置符合引用[2]的标准格式: ```nginx server { listen 443 ssl; # 重点:ssl 直接写在端口后 ssl_certificate /correct/path/fullchain.pem; # 完整证书链 ssl_certificate_key /correct/path/privkey.pem; # 其他配置... } ``` **注意**: - 证书文件需包含完整链(CA 证书 + 域名证书) - 文件权限应为 `600`(避免权限问题) 4. **验证证书链完整性** ```bash openssl verify -CAfile /path/to/ca_bundle.crt your_domain.crt ``` 输出 `OK` 表示完整。 5. **检查系统时间** 运行 `date` 确认服务器时间准确,时区错误会导致证书"提前过期"。 6. **测试连接** 使用 OpenSSL 模拟握手: ```bash openssl s_client -connect upstream_server:443 -servername your_domain.com ``` 观察是否仍报 `certificate expired`。 ### 预防措施 - 设置证书到期提醒(如 Certbot 邮件通知) - 部署自动续签:`certbot renew --quiet --post-hook "systemctl reload nginx"` - 定期检查信任链:`update-ca-certificates`(更新 CA 证书库) > **补充说明**:引用[1]强调 CA 证书需为 PEM 格式,引用[2]演示了正确的 Nginx SSL 配置语法,引用[3]则解释了 TLS 握手失败的根本机制[^1][^2][^3]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值