【问题标题】:Is it possible to use a self signed cert with a EC2 instance that requires a client cert from API Gateway是否可以将自签名证书与需要来自 API Gateway 的客户端证书的 EC2 实例一起使用
【发布时间】:2018-02-24 02:04:37
【问题描述】:

这是我的情况:

我正在使用 Elastic Beanstalk 来启动没有 ELB 的单个 EC2 实例。我想让实例只能通过 API 网关访问。所以,我选择了使用客户端证书进行身份验证,就像here 中描述的那样。

我的 EC2 实例有 Nginx 为 Rails 应用程序提供服务。我在我的机器上生成了一个自签名证书并将 Nginx 配置为使用它通过 https 提供内容。

一切似乎都很好,但是当我尝试从 API Gateway 控制台调用我的代理端点时,我收到一个 500 错误,如下所示:

...
Thu Sep 14 02:27:05 UTC 2017 : Endpoint request URI: https://xxxxxxxxx.xxxxxxxxx.us-east-1.elasticbeanstalk.com/health
Thu Sep 14 02:27:05 UTC 2017 : Endpoint request headers: {x-amzn-apigateway-api-id=xxxxxxxxx, User-Agent=AmazonAPIGateway_xxxxxxxx, Accept-Encoding=identity}
Thu Sep 14 02:27:05 UTC 2017 : Endpoint request body after transformations: 
Thu Sep 14 02:27:05 UTC 2017 : Sending request to https://xxxxxxxxx.xxxxxxxx.us-east-1.elasticbeanstalk.com/health
Thu Sep 14 02:27:05 UTC 2017 : Execution failed due to configuration error: General SSLEngine problem
Thu Sep 14 02:27:05 UTC 2017 : Method completed with status: 500

我认为这与我在后端使用自签名证书这一事实有关。但是我真的必须购买合法证书才能完成我的设置吗?是否有任何其他解决方案允许我仅通过 API 网关接受对我的 EC2 实例的请求?

我查看了here 中描述的 Lambda 方法,但我不想为请求增加任何复杂性或延迟。

为了完整起见,这是我的 Nginx 配置:

server {
      listen       443;
      server_name  localhost;          

      ssl                  on;
      ssl_certificate      /etc/pki/tls/certs/server.crt;
      ssl_certificate_key  /etc/pki/tls/certs/server.key;

      ssl_session_timeout  5m;

      ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
      ssl_prefer_server_ciphers   on;
      ssl_client_certificate /etc/pki/tls/certs/api_gateway.cer;
      ssl_verify_client on;

      if ($ssl_protocol = "") {
        return 444;
      }
  }

【问题讨论】:

    标签: ruby-on-rails amazon-web-services ssl nginx aws-api-gateway


    【解决方案1】:

    在这里查看我的答案AWS API Gateway - Use Client-Side SSL Certificates。不确定与 NGINX 有什么不兼容 - 我设法创建 PoC 并使用 Client-SSL 行为验证身份验证

    【讨论】:

    • 好的,我试试看它是否有效。没有通过 certbot 步骤。这意味着我必须首先获得指向我的 EB 环境域的 CNAME 记录?或者我可以使用 AWS 提供的动态并将其作为 server_name 放在我的 nginx 配置中吗?谢谢。
    【解决方案2】:

    在撰写本文时,API Gateway 似乎有一个known incompatibility with NGINX around Client Certificates

    【讨论】:

    • 这个人真的很烂,特别是因为他们支持的弹性 beanstalk 平台中有一半使用 Nginx 作为代理服务器。除了移动平台或构建我自己的平台之外,您还有什么建议吗?
    猜你喜欢
    • 2022-01-07
    • 1970-01-01
    • 2018-09-21
    • 2013-07-14
    • 2020-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-07
    相关资源
    最近更新 更多