# TLS错误：证书已于<date>过期

- **ID:** `redis/tls-certificate-expired`
- **领域:** redis
- **类别:** config_error
- **错误码:** `ERR`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

Redis使用的TLS证书（服务器或客户端）已过期，导致TLS握手失败并拒绝连接。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 6.0.0 | active | — | — |
| 7.0.0 | active | — | — |
| 7.2.0 | active | — | — |

## 解决方案

1. ```
   生成新的自签名证书：`openssl req -x509 -newkey rsa:4096 -keyout /etc/redis/redis.key -out /etc/redis/redis.crt -days 365 -nodes`，更新redis.conf中的路径，然后重启Redis。
   ```
2. ```
   如果使用CA签名证书，通过CA续期证书并替换证书文件。使用 `redis-cli --tls --cert /path/to/new/cert.pem --key /path/to/new/key.pem` 在重启服务器前测试新证书。
   ```
3. ```
   作为临时措施，将系统时钟设置回证书有效期内的日期（不推荐用于生产），然后重启Redis以允许连接，同时计划正式续期。
   ```

## 无效尝试

- **** — Disabling TLS entirely (e.g., port 6379 without tls-port) exposes data in transit and is not a real fix for environments requiring encryption. (60% 失败率)
- **** — Setting tls-auth-clients to 'no' bypasses client certificate validation but does not fix an expired server certificate; the server certificate must be renewed. (80% 失败率)
