# CloudFront向源站请求超时或失败：源站SSL证书与源站域名不匹配

- **ID:** `aws/cloudfront-invalid-origin-ssl`
- **领域:** aws
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

自定义源站（如ALB、EC2）上的SSL/TLS证书不包含CloudFront分配源站配置中使用的源站域名。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| CloudFront 2023-12-20 | active | — | — |
| ALB 1.0 | active | — | — |
| ACM 2024-01-15 | active | — | — |

## 解决方案

1. ```
   更新源站上的SSL证书，使其包含CloudFront源站配置中使用的域名。对于ALB，使用AWS Certificate Manager：
aws acm request-certificate --domain-name my-origin.example.com --validation-method DNS
# 然后将证书附加到ALB监听器。
   ```
2. ```
   如果使用ALB，将源站域名设置为ALB DNS名称，并确保证书匹配该DNS名称：
# ALB DNS名称：my-alb-1234567890.us-east-1.elb.amazonaws.com
# 证书必须包含*.elb.amazonaws.com或完整的DNS名称。
   ```
3. ```
   使用自定义标头绕过内部源站的SSL验证（如果支持），但这不是标准修复：
# 不推荐；而是修复证书。
   ```

## 无效尝试

- **Disable SSL certificate validation in CloudFront (not possible)** — CloudFront always validates SSL certificates for HTTPS origins; there is no option to disable it. (100% 失败率)
- **Use HTTP instead of HTTPS for the origin protocol** — Switching to HTTP bypasses SSL verification but introduces security risks and may not be allowed by policies. (50% 失败率)
- **Change the origin domain name to an IP address** — IP addresses are not covered by standard SSL certificates; the certificate must match the domain name in the origin configuration. (90% 失败率)
