amazon-web-services - 将自定义域用于 AWS websocket API 网关(使用 CloudFormation)时出现证书错误

标签 amazon-web-services aws-cloudformation amazon-route53 aws-api-gateway amazon-certificate-manager

我在 AWS 中为 Websocket API 网关设置自定义域时遇到了一些问题。我不断收到证书错误。我已经设置了证书和一些云形成脚本。看起来不错。一切都部署正确,但我不断收到有关证书的错误。

$ wscat -c ws.example.com
error: Hostname/IP does not match certificate's altnames: Host: ws.example.com. is not in the cert's altnames: DNS:*.execute-api.us-east-1.amazonaws.com

我检查了它返回的证书,序列号与我在 ACM 中创建的证书不匹配。

这是我的 CloudFormation 脚本:

  WebsocketApi:
    Type: AWS::ApiGatewayV2::Api
    Properties:
      Name: !Sub ${Environment}-ips-ws-api
      ProtocolType: WEBSOCKET
      RouteSelectionExpression: $request.body.action
      ApiKeySelectionExpression: $request.header.x-api-key

  WebsocketStage:
    Type: AWS::ApiGatewayV2::Stage
    Properties: 
      ApiId: !Ref WebsocketApi
      Description: Websocket Api Stage
      StageName: base
      AutoDeploy: true

  WebsocketDomainName:
    Type: AWS::ApiGatewayV2::DomainName
    Properties:
      DomainName: !Ref WebsocketDomain
      DomainNameConfigurations:
        - CertificateArn: !Ref WebsocketCertificateArn
          SecurityPolicy: TLS_1_2
          EndpointType: REGIONAL

  WebsocketDomainMapping:
    Type: AWS::ApiGatewayV2::ApiMapping
    Properties:
      ApiId: !Ref WebsocketApi
      ApiMappingKey: base
      DomainName: !Ref WebsocketDomainName
      Stage: !Ref WebsocketStage

  WebsocketDnsRecord:
    Type: AWS::Route53::RecordSet
    Properties:
      HostedZoneId: !Ref HostedZoneId
      Name: !Ref WebsocketDomain
      Type: CNAME
      AliasTarget:
        DNSName: !GetAtt WebsocketDomainName.RegionalDomainName
        EvaluateTargetHealth: false
        HostedZoneId: !GetAtt WebsocketDomainName.RegionalHostedZoneId

如果我遗漏了一些信息,请告诉我。

任何帮助将不胜感激,我为此绞尽脑汁有一段时间了。

最佳答案

您在使用 wscat 时是否缺少协议(protocol)?你应该像这样使用它:

wscat -c wss://socketserve.example.com

关于amazon-web-services - 将自定义域用于 AWS websocket API 网关(使用 CloudFormation)时出现证书错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73913398/

相关文章:

amazon-web-services - AWS secret 管理器, 'A previous rotation isn’ t complete' 轮换 secret 时

amazon-web-services - 替换 K8 集群中的 AWS ELB

amazon-web-services - Lambda@Edge 事件处理程序的 AWS::Serverless::Function lambda 版本

amazon-web-services - AWS CloudFormation 模板将 IP 地址添加到 Route 53 记录,而不是 URL

amazon-s3 - 使用自定义域的 AWS Lambda 和 S3 静态文件路由

amazon-web-services - 在 S3 存储桶上执行 getObject 操作时如何触发 Lambda 函数?

amazon-web-services - cloudformation模板执行时能否使用该区域最新的Image-id创建EC2实例

amazon-web-services - 尝试在 CloudFormation 上创建堆栈时,状态仅从 CREATE_IN_PROGRESS 更改为 ROLLBACK_COMPLETE

amazon-web-services - 如何为我的 AWS S3 存储桶分配子域?

amazon-web-services - 等待 SSH : Packer experienced an authentication error when trying to connect via SSH 时出错