go auth_error ai_generated true

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

rpc error: code = Unavailable desc = connection closed: tls: failed to verify certificate: x509: certificate has expired or is not yet valid

ID: go/grpc-tls-certificate-expired

其他格式: JSON · Markdown 中文 · English
80%修复率
84%置信度
0证据数
2024-08-05首次发现

版本兼容性

版本状态引入弃用备注
1.2 active

根因分析

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

English

The TLS certificate used by the gRPC server has expired or is not yet valid.

generic

解决方案

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

无效尝试

常见但无效的做法:

  1. Restart the gRPC server without changing certificates. 100% 失败

    Expired certificate remains invalid after restart.

  2. Set system time back to make certificate valid. 50% 失败

    Breaks other services and is a security risk.