gpt4 book ai didi

amazon-web-services - 使用 AWS API Gateway API 的问题

转载 作者:行者123 更新时间:2023-12-04 09:18:46 26 4
gpt4 key购买 nike

我有一个使用 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
任何人都可以帮助解释为什么会这样吗?我已经使用 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.
然后它消失了,它又工作了?嗯?有任何想法吗?

最佳答案

好的,感谢 following post,我找到了问题所在
如果您查看底部原始帖子下方的评论,作者已经解决了问题,但尚未作为帖子的答案,因此您需要通读所有内容才能找到答案。
问题是,您是否需要确保在 route53 中正确设置了 DNS。
我最初是从我的自定义 DN 创建一个 CNAME 到 API 的调用 URL。
相反,您需要做的是创建一个 ALIAS A 记录,从您的自定义 DN 到您的区域 API 的 DN(前缀为 d-*)
注意:这与您的调用 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
}
}
希望这可以在将来为某人节省大量时间。

关于amazon-web-services - 使用 AWS API Gateway API 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63135021/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com