Well, I have a AWS::ApiGateway::RestApi
resource that generates always a url like this: https://{GATEWAYID}.execute-api.{REGION}.amazonaws.com/{STAGE}
So, I created I CNAME in Route 53
, with the following characteristics:
CnameRoute53Api:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneId: !Ref MyHostedZone
Name: api.privatedomain
Type: CNAME
TTL: 300
ResourceRecords:
- !Sub ${GatewayId}.execute-api.${AWS::Region}.amazonaws.com
DependsOn: MyHostedZone
As you can see I'm creating a CNAME inside my private hostedzone
pointing to my gateway. Now I'm trying to make a CURL inside a EC2 in this account:
curl -v https://api.privatedomain
And I got the following error:
url: (51) SSL: no alternative certificate subject name matches target host name 'api.privatedomain'
I understand that SSL certificate is not prepared to accept request from "api.privatedomain". Is there anyway to fix it ? I don't want to buy a custom domain to expose my api to internet, this api will be accessible only inside this account.