我有一个连接到 VPC 端点的私有 API 网关,我 NOT 使用私有 DNS。因此,
https://${aws_api_gateway_rest_api.this.id}-${aws_vpc_endpoint.this.id}.execute-api.${var.region}.amazonaws.com/${var.stage}/${var.path}
形式的 url 是 publicly resolvable per Invoke Private API via VPC Endpoint with Route 53 Alias。这是我组织的其他内部客户端使用的端点,这些客户端来自我们的私有多云网络。
我可以通过以下方式从我的专用网络成功调用此 URL:
curl -v -X POST https://${aws_api_gateway_rest_api.this.id}-${aws_vpc_endpoint.this.id}.execute-api.${var.region}.amazonaws.com/${var.stage}/${var.path}
.
每当 api 网关 id 或 vpc 端点 id 更改时,此 URL 将更改。我需要一个 static url,我可以提供给内部客户,它将 never change.
我在名为
endpoint.sub.domain.com
的公共托管区域中创建名为 sub.domain.com
的 route53 CNAME 记录,并将其指向 ${aws_api_gateway_rest_api.this.id}-${aws_vpc_endpoint.this.id}.execute-api.${var.region}.amazonaws.com
作为静态“代理”,始终指向私有 API 网关的底层公共可解析 DNS 记录.
我像上一个一样卷曲它并收到:
curl -v -X POST https://endoint.sub.domain.com/<stage>/<path>
但有 TLS 问题:
Server certificate:
* subject: CN=*.execute-api.us-east-1.amazonaws.com
* start date: Sep 19 00:00:00 2022 GMT
* expire date: Sep 16 23:59:59 2023 GMT
* subjectAltName does not match endpoint.sub.domain.com
* SSL: no alternative certificate subject name matches target host name 'endpoint.sub.domain.com'
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, close notify (256):
curl: (60) SSL: no alternative certificate subject name matches target host name 'airport-mock-endpoint.npd.nortonalto.com'
More details here: https://curl.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
尝试与
--insecure
相同只是为了看看:curl --insecure -v -X POST https://endoint.sub.domain.com/<stage>/<path>
{"message”:”Forbidden”}
.
同样尝试,这次指定 api 网关 id:
curl --insecure -v -X POST https://endoint.sub.domain.com/<stage>/<path> -H "x-apigw-api-id:5xxxxxxf"
{"message":"Missing Authentication Token"}
尝试相同,这次将 CNAME 记录(原始 url)的目标指定为Host:
curl --insecure -v -X POST https://endoint.sub.domain.com/<stage>/<path> -H "Host: {api-gateway-id}-{vpc-endpoint-id}.execute-api.us-east-2.amazonaws.com"
Api 网关将仅通过称为“自定义域”的功能为您的“静态”域证书提供服务,私有 api 网关不支持该功能。请参阅此 aws 文档中的第一个蓝色注释框:https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html
我知道的唯一可用解决方案在 aws github 中描述https://github.com/aws-samples/serverless-samples/tree/main/apigw-private-custom-domain-name
此解决方案通过在您的私有 api 网关前创建网络负载均衡器来解决此限制,该网关可以配置为使用您的“静态”域证书。