# rpc 错误：代码 = Unavailable 描述 = 连接错误：描述 = "传输层：认证握手失败：tls：客户端未提供证书"

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

## 根因

gRPC 服务器要求双向 TLS（mTLS），但客户端在 TLS 握手期间未提供客户端证书。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   cert, _ := tls.LoadX509KeyPair("client.crt", "client.key"); creds := credentials.NewTLS(&tls.Config{Certificates: []tls.Certificate{cert}}); conn, _ := grpc.Dial(address, grpc.WithTransportCredentials(creds))
   ```
2. **** (85% 成功率)
   ```
   Use a proper CA-signed client certificate and configure the server's CA pool.
   ```

## 无效尝试

- **** — This weakens security and may not be possible in production environments. (60% 失败率)
- **** — Clients typically need a separate client certificate signed by a CA; using the server cert will still fail. (70% 失败率)
