# 不可用：gRPC TLS 握手失败：证书已过期

- **ID:** `grpc/tls-certificate-expiration`
- **领域:** grpc
- **类别:** auth_error
- **错误码:** `GRPC_TLS_CERT_EXPIRED`
- **验证级别:** ai_generated
- **修复率:** 96%

## 根因

gRPC 服务器（或双向 TLS 中的客户端）使用的 TLS 证书已过有效期，导致握手失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC v1.48.x | active | — | — |
| gRPC v1.58.x | active | — | — |
| gRPC v1.64.x | active | — | — |

## 解决方案

1. ```
   续期 TLS 证书：使用 `openssl req -x509 -newkey rsa:4096 -keyout server_key.pem -out server_cert.pem -days 365 -nodes` 生成新证书，然后重启 gRPC 服务器。
   ```
2. ```
   如果使用 Let's Encrypt，运行 `certbot renew` 自动续期证书，然后重新加载 gRPC 服务器（如 `kill -HUP <pid>` 或重启进程）。
   ```
3. ```
   作为临时紧急修复，将系统时钟调回证书有效期范围内（不推荐用于生产），然后重启服务器。
   ```

## 无效尝试

- **** — This bypasses hostname verification but not certificate expiration; the handshake still fails because the certificate itself is invalid. (80% 失败率)
- **** — SSL session caching affects performance, not certificate validation; expiration is checked during full handshake. (50% 失败率)
- **** — The expired certificate remains the same; restarting does not fix the expiration date. (90% 失败率)
