Review API Gateway backend client certificate settings

Configure both the stage and HTTPS backend when the backend authenticates API Gateway with a client certificate.

Description

If an HTTPS backend authenticates API Gateway by client certificate, set client_certificate_id to the certificate the gateway will present. A backend with another suitable authentication method can omit this setting. TLS between callers and API Gateway is configured separately.

Potential impact

  • Legitimate calls may fail if the backend requires a certificate and the gateway has none.
  • A backend without certificate verification or other authentication may accept requests that bypass the gateway.

Remediation

Generate a client certificate in API Gateway and attach it to the stage. Give the HTTPS backend a valid server certificate and configure it to accept only the trusted gateway client certificate. Test both an authorized call and rejection of an unauthorized connection. Update backend trust and rotate the certificate before expiry.

Examples

The excerpts show only the stage. Configure the REST API, deployment, and HTTPS backend integration separately.

Before

hcl
resource "aws_api_gateway_stage" "example" {
  stage_name    = "prod"
  rest_api_id   = aws_api_gateway_rest_api.test.id
  deployment_id = aws_api_gateway_deployment.test.id
}

The prod stage has no client certificate to present to the backend.

After

hcl
resource "aws_api_gateway_stage" "example" {
  stage_name            = "prod"
  rest_api_id           = aws_api_gateway_rest_api.test.id
  deployment_id         = aws_api_gateway_deployment.test.id
  client_certificate_id = var.api_gateway_client_certificate_id
}

Pass the generated certificate ID in api_gateway_client_certificate_id. Configure the backend to verify that certificate.

References