# 502 错误 无法满足请求。CloudFront 无法连接到源站。源的 SSL 证书无效或已过期。

- **ID:** `aws/cloudfront-origin-ssl-handshake-failure`
- **领域:** aws
- **类别:** network_error
- **错误码:** `502`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

CloudFront 无法与自定义源站建立有效的 SSL/TLS 连接，因为源站的 SSL 证书已过期、自签名或与主机名不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| cloudfront-2020-05-31 | active | — | — |
| openssl-3.0.12 | active | — | — |

## 解决方案

1. ```
   在源站服务器上续订 SSL 证书。对于 ALB，使用 AWS Certificate Manager (ACM) 颁发新证书并附加到监听器：`aws elbv2 describe-listeners --load-balancer-arn arn:aws:elasticloadbalancing:...` 然后更新。
   ```
2. ```
   确保证书的通用名称 (CN) 或主题备用名称 (SAN) 与 CloudFront 源站设置中使用的源站域名匹配。
   ```
3. ```
   如果源站是配置为自定义源站的 S3 存储桶，请使用带有 ACM 有效证书的 S3 网站端点。
   ```

## 无效尝试

- **Restart the origin server (e.g., EC2 or ALB)** — Restarting the server doesn't fix an expired or misconfigured certificate; the SSL issue is at the certificate level. (90% 失败率)
- **Disable SSL verification in CloudFront distribution settings** — CloudFront does not allow disabling SSL verification for custom origins; it always validates certificates. (95% 失败率)
