And*_*Kew 7 amazon-web-services aws-lambda aws-api-gateway
我有一个使用 AWS API Gateway 创建的简单 HTTP API,它使用 lambda 集成返回一些数据。我还使用 Route53 (CNAME) 配置了自定义 DN
最近我在调用端点时收到以下错误
Error: Hostname/IP does not match certificate's altnames: Host: xxxxxx. is not in the
cert's altnames:DNS:*.execute-api.eu-west-2.amazonaws.com
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮忙解释为什么会发生这种情况吗?我也使用 AWS 证书管理器为我的自定义域设置了证书,因此它是所有 AWS 服务,但由于某种原因它停止工作了?
谢谢安德鲁
编辑:我奇怪地间歇性地遇到这个问题,当我在浏览器中调用 API 时,出现以下错误:
This server could not prove that it is api.xxxx.co.uk;
its security certificate is from *.execute-api.eu-west-2.amazonaws.com.
This may be caused by a misconfiguration or an attacker
intercepting your connection.
Run Code Online (Sandbox Code Playgroud)
然后它消失并再次起作用?嗯?有任何想法吗?
And*_*Kew 10
好的,由于以下帖子,我已经找到了问题所在
如果您查看底部原始帖子下的评论,作者已经解决了问题,但尚未将其作为帖子的答案,因此您需要通读所有内容才能找到答案。
问题是,您需要确保在 Route53 中正确设置 DNS。我最初是从自定义 DN 到 API 的调用 URL 创建 CNAME。
相反,您需要做的是从您的自定义 DN 到您的区域 API 的 DN(前缀为 d-*)创建一条 ALIAS A 记录
注意:这与您的调用 URL 不同
做出这个改变我所有的问题都消失了。
对于任何在 Terraform 中执行此操作的人来说,这就是您所需要的
//HTTP API using quick create (regional)
resource "aws_apigatewayv2_api" "qc_technical_test" {
name = "qc_technical_test"
protocol_type = "HTTP"
target = aws_lambda_function.tt_lambda.arn
route_key = "GET /persons/address"
}
//custom domain name for API (regional)
resource "aws_apigatewayv2_domain_name" "qc_tt_custom_domain" {
domain_name = "api.${aws_route53_zone.quadcorps.name}"
domain_name_configuration {
certificate_arn = aws_acm_certificate.tt_acm.arn
endpoint_type = "REGIONAL"
security_policy = "TLS_1_2"
}
}
//route53 alias a record to api
resource "aws_route53_record" "tt_api" {
zone_id = aws_route53_zone.quadcorps.zone_id
name = aws_apigatewayv2_domain_name.qc_tt_custom_domain.domain_name
type = "A"
alias {
name = aws_apigatewayv2_domain_name.qc_tt_custom_domain.domain_name_configuration.0.target_domain_name
zone_id = aws_apigatewayv2_domain_name.qc_tt_custom_domain.domain_name_configuration.0.hosted_zone_id
evaluate_target_health = false
}
}
Run Code Online (Sandbox Code Playgroud)
希望这可以在将来为某人节省很多时间。
| 归档时间: |
|
| 查看次数: |
4715 次 |
| 最近记录: |