# httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败：证书不受信任 (_ssl.c:1123)，连接到'https://untrusted.example.com'时

- **ID:** `python/httpx-connecterror-ssl-certificate-verify-failed-untrusted`
- **领域:** python
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

服务器的证书由系统不信任的CA签名。

## 版本兼容性

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

## 解决方案

1. **Properly install the CA certificate in the system trust store** (90% 成功率)
   ```
   # On Windows: import the .crt file into 'Trusted Root Certification Authorities'
# On macOS: sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ca.crt
   ```
2. **Use the verify parameter with the CA certificate file** (85% 成功率)
   ```
   httpx.get('https://untrusted.example.com', verify='/path/to/ca.crt')
   ```

## 无效尝试

- **Adding the certificate to the system trust store incorrectly** — Improper installation may still not make it trusted. (70% 失败率)
- **Using verify=False as a permanent solution** — Disables security and is not recommended for production. (60% 失败率)
