是否可以将自签名证书与需要API Gateway的客户端证书的EC2实例一起使用

时间:2017-09-15 00:43:45

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

这是我的情况:

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

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

一切似乎都很好,但是当我尝试从API网关控制台调用我的代理端点时,我收到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;
      }
  }

2 个答案:

答案 0 :(得分:1)

在撰写本文时,API网关似乎有known incompatibility with NGINX around Client Certificates

答案 1 :(得分:1)

在此处查看我的回答AWS API Gateway - Use Client-Side SSL Certificates。确定与NGINX的不兼容性 - 我设法创建PoC并使用Client-SSL行为验证Authenticate

相关问题