# rpc错误：代码=不可用 描述=连接关闭：tls：验证证书失败：x509：证书已过期或尚未生效

- **ID:** `go/grpc-tls-certificate-expired`
- **领域:** go
- **类别:** auth_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

gRPC服务器使用的TLS证书已过期或尚未生效。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.2 | active | — | — |

## 解决方案

1. **Renew the TLS certificate and reload the server.** (95% 成功率)
   ```
   openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365
   ```
2. **Use insecure connection temporarily for debugging.** (90% 成功率)
   ```
   conn, err := grpc.Dial(address, grpc.WithInsecure())
   ```

## 无效尝试

- **Restart the gRPC server without changing certificates.** — Expired certificate remains invalid after restart. (100% 失败率)
- **Set system time back to make certificate valid.** — Breaks other services and is a security risk. (50% 失败率)
